Documentation ¶
Index ¶
- Constants
- Variables
- func CallLoc(callDepth int) (s string)
- func GenRFCMessage(ts time.Time, prio rfc5424.Priority, hostname, appname, msgid, msg string, ...) ([]byte, error)
- func KV(name string, value interface{}) (r rfc5424.SDParam)
- func KVErr(err error) rfc5424.SDParam
- func PrintOSInfo(wtr io.Writer)
- type KVLogger
- func (kvl *KVLogger) AddKV(sds ...rfc5424.SDParam)
- func (m KVLogger) Appname() string
- func (kvl *KVLogger) Critical(msg string, sds ...rfc5424.SDParam) error
- func (kvl *KVLogger) Debug(msg string, sds ...rfc5424.SDParam) error
- func (kvl *KVLogger) Error(msg string, sds ...rfc5424.SDParam) error
- func (kvl *KVLogger) GetKV() []rfc5424.SDParam
- func (kvl *KVLogger) GetKVMap() map[string]string
- func (m KVLogger) Hostname() string
- func (kvl *KVLogger) Info(msg string, sds ...rfc5424.SDParam) error
- func (m KVLogger) SetAppname(appname string) error
- func (m KVLogger) SetHostname(hostname string) error
- func (kvl *KVLogger) Warn(msg string, sds ...rfc5424.SDParam) error
- type Level
- type LevelRelay
- type Logger
- func (l *Logger) AddLevelRelay(r LevelRelay) error
- func (l *Logger) AddRelay(r Relay) error
- func (l *Logger) AddWriter(wtr io.WriteCloser) error
- func (m *Logger) Appname() string
- func (l *Logger) Close() (err error)
- func (l *Logger) Critical(msg string, sds ...rfc5424.SDParam) error
- func (l *Logger) CriticalWithDepth(d int, msg string, sds ...rfc5424.SDParam) error
- func (l *Logger) Criticalf(f string, args ...interface{}) error
- func (l *Logger) CriticalfWithDepthf(d int, f string, args ...interface{}) error
- func (l *Logger) Debug(msg string, sds ...rfc5424.SDParam) error
- func (l *Logger) DebugWithDepth(d int, msg string, sds ...rfc5424.SDParam) error
- func (l *Logger) Debugf(f string, args ...interface{}) error
- func (l *Logger) DebugfWithDepth(d int, f string, args ...interface{}) error
- func (l *Logger) DeleteRelay(rl Relay) error
- func (l *Logger) DeleteWriter(wtr io.Writer) error
- func (l *Logger) EnableRawMode()
- func (l *Logger) Error(msg string, sds ...rfc5424.SDParam) error
- func (l *Logger) ErrorWithDepth(d int, msg string, sds ...rfc5424.SDParam) error
- func (l *Logger) Errorf(f string, args ...interface{}) error
- func (l *Logger) ErrorfWithDepth(d int, f string, args ...interface{}) error
- func (l *Logger) Fatal(msg string, sds ...rfc5424.SDParam)
- func (l *Logger) FatalCode(code int, msg string, sds ...rfc5424.SDParam)
- func (l *Logger) Fatalf(f string, args ...interface{})
- func (l *Logger) FatalfCode(code int, f string, args ...interface{})
- func (l *Logger) GetLevel() Level
- func (m *Logger) Hostname() string
- func (l *Logger) Info(msg string, sds ...rfc5424.SDParam) error
- func (l *Logger) InfoWithDepth(d int, msg string, sds ...rfc5424.SDParam) error
- func (l *Logger) Infof(f string, args ...interface{}) error
- func (l *Logger) InfofWithDepth(d int, f string, args ...interface{}) error
- func (l *Logger) RawMode() bool
- func (m *Logger) SetAppname(appname string) error
- func (m *Logger) SetHostname(hostname string) error
- func (l *Logger) SetLevel(lvl Level) error
- func (l *Logger) SetLevelString(s string) error
- func (l *Logger) Warn(msg string, sds ...rfc5424.SDParam) error
- func (l *Logger) WarnWithDepth(d int, msg string, sds ...rfc5424.SDParam) error
- func (l *Logger) Warnf(f string, args ...interface{}) error
- func (l *Logger) WarnfWithDepth(d int, f string, args ...interface{}) error
- func (l *Logger) Write(b []byte) (n int, err error)
- type Relay
- type StderrCallback
Constants ¶
const ( DEFAULT_DEPTH = 3 DefaultID = `gw@1` )
Variables ¶
var ( ErrNotOpen = errors.New("Logger is not open") ErrInvalidLevel = errors.New("Log level is invalid") )
Functions ¶
func GenRFCMessage ¶ added in v3.8.4
func GenRFCMessage(ts time.Time, prio rfc5424.Priority, hostname, appname, msgid, msg string, sds ...rfc5424.SDParam) ([]byte, error)
Per RFC5424 https://www.rfc-editor.org/rfc/rfc5424.html#section-6.2.7
There are maximum lengths for some of the fields below:
AppName: 48 ProcID: 128 MsgID: 32 Hostname: 255
func PrintOSInfo ¶ added in v3.8.6
Types ¶
type KVLogger ¶ added in v3.8.5
type KVLogger struct { *Logger // contains filtered or unexported fields }
func NewLoggerWithKV ¶ added in v3.8.5
func (*KVLogger) Critical ¶ added in v3.8.5
Critical writes a CRITICALinfo level log to the underlying writer, if the logging level is higher than DEBUG no action is taken
func (*KVLogger) Debug ¶ added in v3.8.5
Debug writes a DEBUG level log to the underlying writer, if the logging level is higher than DEBUG no action is taken
func (*KVLogger) Error ¶ added in v3.8.5
Error writes an ERROR level log to the underlying writer, if the logging level is higher than DEBUG no action is taken
func (*KVLogger) GetKVMap ¶ added in v3.8.23
GetKVMap returns the structured data elements as a map[string]string
func (*KVLogger) Info ¶ added in v3.8.5
Infof writes an INFO level log to the underlying writer using a format string, if the logging level is higher than DEBUG no action is taken
func (KVLogger) SetAppname ¶ added in v3.8.5
func (KVLogger) SetHostname ¶ added in v3.8.5
type LevelRelay ¶ added in v3.8.10
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
func New ¶
func New(wtr io.WriteCloser) (l *Logger)
New creates a new logger with the given writer at log level INFO
func NewDiscardLogger ¶
func NewDiscardLogger() *Logger
func NewFile ¶
NewFile creates a new logger with the first writer being a file The file is created if it does not exist, and is opened in append mode it is safe to use NewFile on existing logs
func NewLevelRelay ¶ added in v3.8.26
func NewLevelRelay(lr LevelRelay) (l *Logger)
NewLevelRelay creates a new logger with just a level relay
func NewStderrLogger ¶
func NewStderrLoggerEx ¶
func NewStderrLoggerEx(fileOverride string, cb StderrCallback) (*Logger, error)
func (*Logger) AddLevelRelay ¶ added in v3.8.10
func (l *Logger) AddLevelRelay(r LevelRelay) error
AddLevelRelay will add a new relay which will get all log entries as they are handled.
func (*Logger) AddRelay ¶ added in v3.8.0
AddRelay will add a new relay which will get all log entries as they are handled.
func (*Logger) AddWriter ¶
func (l *Logger) AddWriter(wtr io.WriteCloser) error
AddWriter will add a new writer which will get all the log lines as they are handled.
func (*Logger) Close ¶
Close closes the logger and all currently associated writers writers that have been deleted are NOT closed
func (*Logger) Critical ¶
Critical writes a CRITICALinfo level log to the underlying writer, if the logging level is higher than DEBUG no action is taken
func (*Logger) CriticalWithDepth ¶
CriticalfWithDepth writes a CRITICALinfo level log to the underlying writer, if the logging level is higher than DEBUG no action is taken
func (*Logger) Criticalf ¶ added in v3.8.4
Critical writes a CRITICALinfo level log to the underlying writer, if the logging level is higher than DEBUG no action is taken
func (*Logger) CriticalfWithDepthf ¶ added in v3.8.4
CriticalfWithDepth writes a CRITICALinfo level log to the underlying writer, if the logging level is higher than DEBUG no action is taken
func (*Logger) Debug ¶
Debug writes a DEBUG level log to the underlying writer, if the logging level is higher than DEBUG no action is taken
func (*Logger) DebugWithDepth ¶
DebugWithDepth writes a DEBUG level log to the underlying writer, if the logging level is higher than DEBUG no action is taken
func (*Logger) Debugf ¶ added in v3.8.4
Debug writes a DEBUG level log to the underlying writer, if the logging level is higher than DEBUG no action is taken
func (*Logger) DebugfWithDepth ¶ added in v3.8.4
DebugfWithDepth writes a DEBUG level log to the underlying writer, if the logging level is higher than DEBUG no action is taken
func (*Logger) DeleteRelay ¶ added in v3.8.0
DeleteRelay removes a relay from the logger.
func (*Logger) DeleteWriter ¶
DeleteWriter removes a writer from the logger, it will not be closed on logging Close
func (*Logger) EnableRawMode ¶ added in v3.8.0
func (l *Logger) EnableRawMode()
func (*Logger) Error ¶
Error writes an ERROR level log to the underlying writer, if the logging level is higher than DEBUG no action is taken
func (*Logger) ErrorWithDepth ¶
ErrorfWithDepth writes an ERROR level log to the underlying writer, if the logging level is higher than DEBUG no action is taken
func (*Logger) Errorf ¶ added in v3.8.4
Error writes an ERROR level log to the underlying writer, if the logging level is higher than DEBUG no action is taken
func (*Logger) ErrorfWithDepth ¶ added in v3.8.4
ErrorfWithDepth writes an ERROR level log to the underlying writer, if the logging level is higher than DEBUG no action is taken
func (*Logger) FatalCode ¶
FatalCode is identical to a log.Fatal, except it allows for controlling the exit code
func (*Logger) Fatalf ¶ added in v3.8.4
Fatal writes a log, closes the logger, and issues an os.Exit(-1)
func (*Logger) FatalfCode ¶ added in v3.8.4
FatalCode is identical to a log.Fatal, except it allows for controlling the exit code
func (*Logger) Info ¶
Infof writes an INFO level log to the underlying writer using a format string, if the logging level is higher than DEBUG no action is taken
func (*Logger) InfoWithDepth ¶
InfofWithDepth writes an INFO level log to the underlying writer, if the logging level is higher than DEBUG no action is taken
func (*Logger) Infof ¶ added in v3.8.4
Infof writes an INFO level log to the underlying writer using a format string, if the logging level is higher than DEBUG no action is taken
func (*Logger) InfofWithDepth ¶ added in v3.8.4
InfofWithDepth writes an INFO level log to the underlying writer, if the logging level is higher than DEBUG no action is taken
func (*Logger) SetAppname ¶ added in v3.8.0
func (*Logger) SetHostname ¶ added in v3.8.0
func (*Logger) SetLevel ¶
SetLevel sets the log level, Off disables logging and any logging call that is less than the level current level are not logged
func (*Logger) SetLevelString ¶
SetLevelString sets the log level using a string, this is a helper function so that you can just hand the config file value directly in
func (*Logger) Warn ¶
Warn writes an WARN level log to the underlying writer, if the logging level is higher than DEBUG no action is taken
func (*Logger) WarnWithDepth ¶
WarnfWithDepth writes an WARN level log to the underlying writer, if the logging level is higher than DEBUG no action is taken
func (*Logger) Warnf ¶ added in v3.8.4
Warn writes an WARN level log to the underlying writer, if the logging level is higher than DEBUG no action is taken
func (*Logger) WarnfWithDepth ¶ added in v3.8.4
WarnfWithDepth writes an WARN level log to the underlying writer, if the logging level is higher than DEBUG no action is taken