SyslogAction

Enum SyslogAction 

Source
#[repr(i32)]
pub enum SyslogAction { Close = 0, Open = 1, Read = 2, ReadAll = 3, ReadClear = 4, Clear = 5, ConsoleOff = 6, ConsoleOn = 7, ConsoleLevel = 8, SizeUnread = 9, SizeBuffer = 10, }
Expand description

syslog 系统调用操作类型

与 Linux 内核 SYSLOG_ACTION_* 常量完全兼容。 使用 enum 而非原始常量以提供类型安全和编译器优化。

Variants§

§

Close = 0

关闭日志 (NOP)

Linux 中此操作为空操作,保留用于历史兼容性。

§

Open = 1

打开日志 (NOP)

Linux 中此操作为空操作,保留用于历史兼容性。

§

Read = 2

从日志读取(破坏性)

读取内核日志并从缓冲区移除已读条目。 需要:bufp != NULL, len > 0 权限:CAP_SYSLOG 或 CAP_SYS_ADMIN

§

ReadAll = 3

读取所有日志(非破坏性)

读取内核日志但不从缓冲区移除。 需要:bufp != NULL, len > 0 权限:如果 dmesg_restrict=0,允许非特权访问

§

ReadClear = 4

读取并清空

先读取日志,然后清空缓冲区。 需要:bufp != NULL, len > 0 权限:CAP_SYSLOG 或 CAP_SYS_ADMIN

§

Clear = 5

清空缓冲区

清除所有已缓冲的日志条目。 权限:CAP_SYSLOG 或 CAP_SYS_ADMIN

§

ConsoleOff = 6

禁用控制台输出

将 console_loglevel 设置为最小值(只显示 EMERG)。 权限:CAP_SYSLOG 或 CAP_SYS_ADMIN

§

ConsoleOn = 7

启用控制台输出

恢复控制台输出到默认级别(通常为 WARNING)。 权限:CAP_SYSLOG 或 CAP_SYS_ADMIN

§

ConsoleLevel = 8

设置控制台日志级别

设置 console_loglevel,控制哪些日志显示在控制台。 len 参数范围:1-8 权限:CAP_SYSLOG 或 CAP_SYS_ADMIN

§

SizeUnread = 9

获取未读字节数

返回当前缓冲区中未读日志的估计字节数。 权限:如果 dmesg_restrict=0,允许非特权访问

§

SizeBuffer = 10

获取缓冲区总大小

返回内核日志缓冲区的总容量(字节)。 权限:如果 dmesg_restrict=0,允许非特权访问

Implementations§

Source§

impl SyslogAction

Source

pub const fn from_i32(value: i32) -> Result<Self, i32>

从原始 i32 值转换为 SyslogAction

Source

pub const fn requires_buffer(self) -> bool

检查操作是否需要有效的用户缓冲区

§返回值
  • true - 需要 bufp != NULL 且 len > 0
  • false - 忽略 bufp 和 len 参数
Source

pub const fn requires_privilege(self) -> bool

检查操作是否需要特权

注意:ReadAll 和 SizeBuffer 在 dmesg_restrict=0 时允许非特权访问。

§返回值
  • true - 总是需要权限检查
  • false - 可能允许非特权访问(需要进一步检查 dmesg_restrict)
Source

pub const fn is_destructive(self) -> bool

检查操作是否会修改日志缓冲区

用于并发控制和日志审计。

Source

pub const fn affects_console(self) -> bool

检查操作是否影响控制台输出

Source

pub const fn as_str(self) -> &'static str

获取操作的字符串描述(用于日志和调试)

Trait Implementations§

Source§

impl Clone for SyslogAction

Source§

fn clone(&self) -> SyslogAction

Returns a duplicate of the value. Read more
1.0.0§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SyslogAction

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for SyslogAction

Source§

fn eq(&self, other: &SyslogAction) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for SyslogAction

Source§

impl Eq for SyslogAction

Source§

impl StructuralPartialEq for SyslogAction

Auto Trait Implementations§

§

impl Freeze for SyslogAction

§

impl RefUnwindSafe for SyslogAction

§

impl Send for SyslogAction

§

impl Sync for SyslogAction

§

impl Unpin for SyslogAction

§

impl UnwindSafe for SyslogAction

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CloneToUninit for T
where T: Clone,

§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.