Documentation ¶
Index ¶
- Constants
- func Debugf(format string, args ...interface{})
- func Errorf(format string, args ...interface{})
- func Infof(format string, args ...interface{})
- func Init(l ...Logger)
- func InitWithConfig(configs ...Config) error
- func Logfmt(callDepth int, sev Severity, format string, args ...interface{})
- func SetSeverity(sev Severity)
- func Warningf(format string, args ...interface{})
- type CallerInfo
- type Config
- type LogWriter
- type Logger
- type Severity
Constants ¶
View Source
const ( Console = "console" Syslog = "syslog" UDPLog = "udplog" )
Supported log types.
View Source
const ( DefaultHost = "127.0.0.1" DefaultPort = 55647 DefaultCategory = "go_logging" )
Variables ¶
This section is empty.
Functions ¶
func Errorf ¶
func Errorf(format string, args ...interface{})
Errorf logs to the ERROR, WARN, and INFO logs.
func InitWithConfig ¶
InitWithConfig instantiates loggers based on the provided configs and initializes the package with them.
func Logfmt ¶
Logfmt logs a formatted message of the specified severity, marking it attributed to a function at the specified depth on the current goroutine stack.
func SetSeverity ¶
func SetSeverity(sev Severity)
Types ¶
type CallerInfo ¶
CallerInfo encapsulates information about a piece of code that called a certain log function, such as file name, line number, etc.
type Config ¶
type Config struct { // Name is a logger's identificator used to instantiate a proper logger type // from a config. Name string // Severity indicates the minimum severity a logger will be logging messages at. Severity string }
Config represents a configuration of an individual logger.
type LogWriter ¶
type LogWriter interface { Infof(format string, args ...interface{}) Warningf(format string, args ...interface{}) Errorf(format string, args ...interface{}) }
func GetGlobalLogger ¶
func GetGlobalLogger() LogWriter
type Logger ¶
type Logger interface { // Writer returns logger's underlying io.Writer used to write log messages to. // // It may be, for example, the standard output for a console logger or a socket // connection for a UDP logger. // // Should return `nil` if the logger is not supposed to log at the specified severity. Writer(Severity) io.Writer // FormatMessage constructs and returns a final message that will go to the logger's // output channel. FormatMessage(Severity, *CallerInfo, string, ...interface{}) string // Sets a loggers current Severity level. SetSeverity(Severity) // Gets the current Severity level. GetSeverity() Severity }
Logger is an interface that should be implemented by all loggers wishing to participate in the logger chain initialized by this package.
func NewConsoleLogger ¶
func NewSysLogger ¶
func NewUDPLogger ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.