Compare commits
4 Commits
8b0bd8ba22
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| db30b03f8f | |||
| 62e3eac0a9 | |||
| 75cf71e917 | |||
| 7f444673ad |
2
LICENSE
2
LICENSE
@@ -1,6 +1,6 @@
|
|||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (c) <year> <copyright holders>
|
Copyright (c) 2023 Larv IT AB
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
|||||||
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"}
|
||||||
```
|
```
|
||||||
2
go.mod
2
go.mod
@@ -2,7 +2,7 @@ module gitea.larvit.se/pwrpln/go_log
|
|||||||
|
|
||||||
go 1.19
|
go 1.19
|
||||||
|
|
||||||
require github.com/stretchr/testify v1.8.0
|
require github.com/stretchr/testify v1.8.1
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||||
|
|||||||
4
go.sum
4
go.sum
@@ -5,9 +5,11 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
|
|||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||||
|
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
|
|
||||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||||
|
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
|
||||||
|
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
|
|||||||
Reference in New Issue
Block a user