Categorygithub.com/cloudokyo/log
modulepackage
0.0.2
Repository: https://github.com/cloudokyo/log.git
Documentation: pkg.go.dev

# README

Log

Provides the library to write logs to console or JSON

Reference

# Functions

Attach the logger data into echo.Context Injection - id: The request id - uid: The user id (TBD) - did: The user device id (TBD) - cid: The user active channel id (TBD) - agent: The user browser UserAgent (TBD) Example ctx := log.Attach(ctx).
Ctx returns the Logger associated with the ctx.
Write a log to output with DEBUG level Example log.Debug("hello", "world").Send().
Write a log with format to output with DEBUG level Example log.Debugf("hello %s", "world").
Get the default logger instance Example log := log.Default().
Detach the logger data injected to the context Example log.Detach(ctx) --> {"id": "xxx"}.
Write a log to output with ERROR level Example log.Error("hello", "world").Send().
Write a log with format to output with ERROR level Example log.Errorf("hello %s", "world").
Write a log to output with FATAL level and call os.Exit(1) Example log.Fatal("hello", "world").Send().
Write a log with format to output with FATAL level and call os.Exit(1) Example log.Fatalf("hello %s", "world").
Write a log to output with INFO level Example log.Info("hello", "world").Send().
Write a log with format to output with INFO level Example log.Infof("hello %s", "world").
Level creates a child logger with the minimum accepted level set to level.
Write an event to log output Param event: The zerolog event args: The data injected to the log Example log.Log(event, "Test log event message").Send().
Write an event to log output with format Param event: The zerolog event args: The data injected to the log Example log.Logf(event, "Test log event message").
MarshalStack implements pkg/errors stack trace marshaling.
Set the log output Example log.Output(os.Stdout).
Write a log to output with PANIC level and PANIC Example log.Panic("hello", "world").Send().
Write a log with format to output with PANIC level and PANIC Example log.Panicf("hello %s", "world").
Get the requestId has injected to the context Example log.RequestId(ctx).
Cast an object to string with JSON or formatter Example log.String(data) --> string.
Write a log to output with TRACE level Example log.Trace("hello", "world").
Write a log with format to output with TRACE level Example log.Tracef("hello %s", "world").
Write a log to output with WARN level Example log.Warn("hello", "world").Send().
Write a log with format to output with WARN level Example log.Warnf("hello %s", "world").
With creates a child logger with the field added to its context.
Attach the data to the context.Context Example ctx := log.WithValue(ctx, "key", "value").

# Constants

The auth account key, refer to pkg/http/filter/auth.ContextKey.
A log field.
The client id key attaches to the context.
The key attachs the logger data to the context.
The device id key attaches to the context.
A log field.
The request id key attaches to the context.
The request user agent key attaches to the context.
The user id key attaches to the context.

# Variables

An alias function of log.Attach.
Log to console mode.
Log level, default=DEBUG - UAT: DEBUG - PROD: INFO Env LOG_LEVEL=DEBUG.
The console log color Env LOG_NOCOLOR=true.
Log error stack trace.
Log trace mode.
The default console log output.
The default log output is os.Stdout.
An alias of log.Print function.
An alias of log.Printf function.
An alias of log.Println function.
An alias function of log.Attach.

# Type aliases

Define the injection data struct to context.
No description provided by the author
Define the context key to inject data in to context.
No description provided by the author