Documentation ¶
Overview ¶
Package log provides a application log that formalize a log format.
logger, err := log.New() if err != nil { panic(err) } defer logger.Close() logger.Info("This is my log", log.String("Key", "String value"))
Example (Basic) ¶
package main import ( "github.com/anthonycorbacho/foundation/log" ) func main() { logger, err := log.New() if err != nil { panic(err) } defer logger.Close() logger.Info("This is my log", log.String("Key", "String value")) }
Output:
Index ¶
- type Field
- func Any(key string, val interface{}) Field
- func Bool(key string, val bool) Field
- func ByteString(key string, val []byte) Field
- func Duration(key string, val time.Duration) Field
- func Error(err error) Field
- func Float32(key string, val float32) Field
- func Float64(key string, val float64) Field
- func Int(key string, val int) Field
- func Int32(key string, val int32) Field
- func Int64(key string, val int64) Field
- func String(key string, val string) Field
- func Stringer(key string, val fmt.Stringer) Field
- func Time(key string, val time.Time) Field
- type Logger
- type ZapLogger
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Field ¶
Field is a marshaling operation used to add a key-value pair to a logger's context.
func ByteString ¶
ByteString constructs a field with the given key and value.
type Logger ¶
type Logger interface { // Debug logs a message at DebugLevel. Debug(msg string, fields ...Field) // Info logs a message at InfoLevel. Info(msg string, fields ...Field) // Warn logs a message at WarnLevel. Warn(msg string, fields ...Field) // Error logs a message at ErrorLevel. Error(msg string, fields ...Field) // Fatal logs a message at FatalLevel. Fatal(msg string, fields ...Field) // Panic logs a message at PanicLevel. Panic(msg string, fields ...Field) // Close closes the logger. Close() }
Logger defines a leveled logging structure.
Click to show internal directories.
Click to hide internal directories.