Documentation ¶
Overview ¶
Package syslog provides a wrapper for system log functionality, allowing for logging messages with various priorities and optional console output.
Index ¶
- Constants
- type Syslog
- func (s *Syslog) Close()
- func (s *Syslog) Crit(message string)
- func (s *Syslog) Critf(format string, a ...interface{})
- func (s *Syslog) DisableConsole()
- func (s *Syslog) EnableConsole()
- func (s *Syslog) Error(message string)
- func (s *Syslog) Errorf(format string, a ...interface{})
- func (s *Syslog) Info(message string)
- func (s *Syslog) Infof(format string, a ...interface{})
- func (s *Syslog) Log(priority int, message string)
- func (s *Syslog) Warn(message string)
- func (s *Syslog) Warnf(format string, a ...interface{})
Constants ¶
const ( LOG_PID = 0x01 LOG_CONS = 0x02 LOG_USER = (1 << 3) LOG_INFO = 6 LOG_CRIT = 2 LOG_WARN = 4 LOG_ERR = 3 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Syslog ¶
type Syslog struct {
// contains filtered or unexported fields
}
Syslog struct holds the identifier pointer for syslog entries and a flag to enable or disable console logging.
func NewSyslog ¶
NewSyslog initializes a new syslog handler with the specified identifier, option, and facility. Console logging is disabled by default. - `ident` is a string that identifies the messages in the log. - `option` is an integer specifying logging options (e.g., LOG_PID, LOG_CONS). - `facility` is an integer specifying the syslog facility.
func (*Syslog) Close ¶
func (s *Syslog) Close()
Close releases resources associated with the syslog, specifically freeing the identifier.
func (*Syslog) Crit ¶
Crit logs a critical message to the syslog and panics. The message is also logged to the console if console logging is enabled.
func (*Syslog) Critf ¶
Critf logs a critical message, formatted according to a format specifier, to the syslog and panics. The message is also logged to the console if console logging is enabled.
func (*Syslog) DisableConsole ¶
func (s *Syslog) DisableConsole()
DisableConsole disables logging to the console for this syslog instance.
func (*Syslog) EnableConsole ¶
func (s *Syslog) EnableConsole()
EnableConsole enables logging to the console for this syslog instance.
func (*Syslog) Errorf ¶
Errorf logs an error message, formatted according to a format specifier, to the syslog, and optionally to the console.
func (*Syslog) Info ¶
Info logs an informational message to the syslog, and optionally to the console.
func (*Syslog) Infof ¶
Infof logs an informational message, formatted according to a format specifier, to the syslog, and optionally to the console.
func (*Syslog) Log ¶
Log sends a log message with the specified priority to the syslog, and optionally to the console if console logging is enabled. - `priority` is an integer specifying the message's priority (e.g., LOG_INFO, LOG_ERR). - `message` is the string message to log.