Documentation
¶
Overview ¶
Use conditional logging methods to potentially suppress log messages based on situations orthogonal to log level, with "log sometimes" or "log rarely" semantics. Combine with Composers to to avoid expensive message building operations.
Global Logging Infrastructure ¶
By default (following from the standard library logger and other popular logging pacakges,) grip provides a "default" package level logging instance. This logging instance is accessible via a number of package functions which mirror the interface of the Logger type itself.
During init() this logging instance wraps and uses the underlying writer of the standard library's logger. You can use SetGlobalLogger to configure your own logging (and sender!) infrastructure for default operations, though this function is not thread safe.
In many cases, it might make sense to attach a Logger instance to a context, as Logging is a global concern and your application is likely already using contexts. The WithLogger and Context method make it possible to attach and access your logger. The Context method will *always* return a Logging instance, either the instance attached to a context or the global instance if one is not configured.
Basic Logger ¶
The Logger type provides helpers for sending messages at the following levels:
Emergency + (fatal/panic) Alert Critical Error Warning Notice Info Debug
These helpers also include Log* helpers to parameterize the level, as well as the Send method for default logging (or when the level is on the massage itself.)
Index ¶
- func Alert(msg interface{})
- func AlertWhen(conditional bool, m interface{})
- func Alertf(msg string, a ...interface{})
- func Alertln(a ...interface{})
- func Build() *message.Builder
- func Critical(msg interface{})
- func CriticalWhen(conditional bool, m interface{})
- func Criticalf(msg string, a ...interface{})
- func Criticalln(a ...interface{})
- func Debug(msg interface{})
- func DebugWhen(conditional bool, m interface{})
- func Debugf(msg string, a ...interface{})
- func Debugln(a ...interface{})
- func Emergency(msg interface{})
- func EmergencyFatal(msg interface{})
- func EmergencyPanic(msg interface{})
- func EmergencyWhen(conditional bool, m interface{})
- func Emergencyf(msg string, a ...interface{})
- func Emergencyln(a ...interface{})
- func Error(msg interface{})
- func ErrorWhen(conditional bool, m interface{})
- func Errorf(msg string, a ...interface{})
- func Errorln(a ...interface{})
- func Info(msg interface{})
- func InfoWhen(conditional bool, message interface{})
- func Infof(msg string, a ...interface{})
- func Infoln(a ...interface{})
- func Log(l level.Priority, msg interface{})
- func LogWhen(conditional bool, l level.Priority, m interface{})
- func Logf(l level.Priority, msg string, a ...interface{})
- func Logln(l level.Priority, a ...interface{})
- func Notice(msg interface{})
- func NoticeWhen(conditional bool, m interface{})
- func Noticef(msg string, a ...interface{})
- func Noticeln(a ...interface{})
- func Sender() send.Sender
- func SetGlobalLogger(l Logger)
- func Trace(msg interface{})
- func TraceWhen(conditional bool, m interface{})
- func Tracef(msg string, a ...interface{})
- func Traceln(a ...interface{})
- func Warning(msg interface{})
- func WarningWhen(conditional bool, m interface{})
- func Warningf(msg string, a ...interface{})
- func Warningln(a ...interface{})
- func WithLogger(ctx context.Context, logger Logger) context.Context
- type Logger
- func (g Logger) Alert(m any)
- func (g Logger) AlertWhen(c bool, m any)
- func (g Logger) Alertf(m string, a ...any)
- func (g Logger) Alertln(a ...any)
- func (g Logger) Build() *message.Builder
- func (g Logger) Critical(m any)
- func (g Logger) CriticalWhen(c bool, m any)
- func (g Logger) Criticalf(m string, a ...any)
- func (g Logger) Criticalln(a ...any)
- func (g Logger) Debug(m any)
- func (g Logger) DebugWhen(c bool, m any)
- func (g Logger) Debugf(m string, a ...any)
- func (g Logger) Debugln(a ...any)
- func (g Logger) Emergency(m any)
- func (g Logger) EmergencyFatal(m any)
- func (g Logger) EmergencyPanic(m any)
- func (g Logger) EmergencyWhen(c bool, m any)
- func (g Logger) Emergencyf(m string, a ...any)
- func (g Logger) Emergencyln(a ...any)
- func (g Logger) Error(m any)
- func (g Logger) ErrorWhen(c bool, m any)
- func (g Logger) Errorf(m string, a ...any)
- func (g Logger) Errorln(a ...any)
- func (g Logger) Info(m any)
- func (g Logger) InfoWhen(c bool, m any)
- func (g Logger) Infof(m string, a ...any)
- func (g Logger) Infoln(a ...any)
- func (g Logger) Log(l level.Priority, m any)
- func (g Logger) LogWhen(c bool, l level.Priority, m any)
- func (g Logger) Logf(l level.Priority, msg string, a ...any)
- func (g Logger) Logln(l level.Priority, a ...any)
- func (g Logger) Notice(m any)
- func (g Logger) NoticeWhen(c bool, m any)
- func (g Logger) Noticef(m string, a ...any)
- func (g Logger) Noticeln(a ...any)
- func (g Logger) Sender() send.Sender
- func (g Logger) Trace(m any)
- func (g Logger) TraceWhen(c bool, m any)
- func (g Logger) Tracef(m string, a ...any)
- func (g Logger) Traceln(a ...any)
- func (g Logger) Warning(m any)
- func (g Logger) WarningWhen(c bool, m any)
- func (g Logger) Warningf(m string, a ...any)
- func (g Logger) Warningln(a ...any)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CriticalWhen ¶
func CriticalWhen(conditional bool, m interface{})
func Criticalln ¶
func Criticalln(a ...interface{})
func EmergencyFatal ¶
func EmergencyFatal(msg interface{})
func EmergencyPanic ¶
func EmergencyPanic(msg interface{})
func EmergencyWhen ¶
func EmergencyWhen(conditional bool, m interface{})
func Emergencyf ¶
func Emergencyf(msg string, a ...interface{})
func Emergencyln ¶
func Emergencyln(a ...interface{})
func NoticeWhen ¶
func NoticeWhen(conditional bool, m interface{})
func SetGlobalLogger ¶
func SetGlobalLogger(l Logger)
SetGlobalJournaler allows you to override the standard logger, that is used by calls in the grip package. This call is not thread safe relative to other logging calls, or the GetGlobalJournaler call, although all journaling methods are safe: as a result be sure to only call this method during package and process initialization.
func WarningWhen ¶
func WarningWhen(conditional bool, m interface{})
Types ¶
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger provides the public interface of the grip Logger.
Package level functions mirror all methods on the Logger type to access a "global" Logger instance in the grip package.
func Context ¶
Context resolves a logger from the given context, and if one does not exist (or the context is nil), produces the global Logger instance.
func (Logger) CriticalWhen ¶
func (Logger) Criticalln ¶
func (Logger) EmergencyFatal ¶
func (Logger) EmergencyPanic ¶
func (Logger) EmergencyWhen ¶
func (Logger) Emergencyf ¶
func (Logger) Emergencyln ¶
func (Logger) NoticeWhen ¶
func (Logger) WarningWhen ¶
Directories
¶
Path | Synopsis |
---|---|
Package level defines a Priority type and some conversion methods for a 7-tiered logging level schema, which mirror syslog and system's logging levels.
|
Package level defines a Priority type and some conversion methods for a 7-tiered logging level schema, which mirror syslog and system's logging levels. |
package message defines the Composer interface and a handful of implementations which represent the structure for messages produced by grip.
|
package message defines the Composer interface and a handful of implementations which represent the structure for messages produced by grip. |
Package recovery provides a number of grip-integrated panic handling tools for capturing and responding to panics using grip loggers.
|
Package recovery provides a number of grip-integrated panic handling tools for capturing and responding to panics using grip loggers. |
Call Site Sender
|
Call Site Sender |
x
|
|
desktop
Module
|
|
email
Module
|
|
github
Module
|
|
graphite
Module
|
|
jira
Module
|
|
metrics
Module
|
|
slack
Module
|
|
splunk
Module
|
|
sumologic
Module
|
|
system
Module
|
|
telegram
Module
|
|
twitter
Module
|
|
xmpp
Module
|
|
zap
Module
|
|
zerolog
Module
|