Compare commits
2 Commits
75cf71e917
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| db30b03f8f | |||
| 62e3eac0a9 |
24
README.md
24
README.md
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
`go get -u https://gitea.larvit.se/pwrpln/go_log`
|
`go get -u gitea.larvit.se/pwrpln/go_log`
|
||||||
|
|
||||||
## Example usage
|
## Example usage
|
||||||
|
|
||||||
@@ -57,13 +57,21 @@ log.Info("Zep", "other", "stuff")
|
|||||||
All available options, and their defaults:
|
All available options, and their defaults:
|
||||||
|
|
||||||
```go
|
```go
|
||||||
loc, _ := time.LoadLocation("UTC")
|
loc, _ := time.LoadLocation("UTC") // See more info at https://pkg.go.dev/time#LoadLocation
|
||||||
log := go_log.Log{
|
log := go_log.Log{
|
||||||
Context: []interface{}, // Will be prepended to metadata on all log entries
|
Context: []interface{}{}, // Will be prepended to metadata on all log entries
|
||||||
MinLogLvl: go_log.Info, // Minimal log level to output
|
MinLogLvl: go_log.LogLvlFromStr("Info"), // Minimal log level to output
|
||||||
Fmt: go_log.DefaultFmt, // Log message formatter
|
Fmt: go_log.DefaultFmt, // Log message formatter
|
||||||
Stderr: go_log.DefaultStderr, // Log message outputter for Debug, Verbose and Info
|
Stderr: go_log.DefaultStderr, // Log message outputter for Debug, Verbose and Info
|
||||||
Stdout: go_log.DefaultStdout, // Log message outputter for Warning and Error
|
Stdout: go_log.DefaultStdout, // Log message outputter for Warning and Error
|
||||||
TimeLocation: loc, // Timestamp location/time zone setting
|
TimeLocation: loc, // Timestamp location/time zone setting
|
||||||
}
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Or change them after initialization like this:
|
||||||
|
|
||||||
|
```go
|
||||||
|
log := go_log.GetLog()
|
||||||
|
log.MinLogLvl = go_log.LogLvlFromStr("Debug")
|
||||||
|
log.Context = []interface{}{"key1", "value1", "key2", "value2"}
|
||||||
```
|
```
|
||||||
Reference in New Issue
Block a user