To use GoCenter:
export GOPROXY=https://gocenter.io
bitbucket.org/snapmartinc/logger
January 1st 0001
Last Modified
0
Stars
Unknown
License
41
Downloads
ReadMe
Mod File
GoDocs
New
Security
Dependencies (0)
Used By (0)
Metrics
Versions
logger GO library
Install
import:
- package: bitbucket.org/snapmartinc/logger
version: x.x.x
Rules:
Message is truncated at 128 characters
Level table
Priority | #1 | #2 | #3 | #4 | #5 | #6 | #7 | #8 |
---|---|---|---|---|---|---|---|---|
Level | emerg | alert | crit | err | warning | notice | info | debug |
There are 8 Levels to provide to LoggerProvider
EmergencyLevel
AlertLevel
CriticalLevel
ErrorLevel
WarningLevel
NoticeLevel
InfoLevel
DebugLevel
````
### Examples:
##### With content field
```go
package main
import (
"bitbucket.org/snapmartinc/logger"
"context"
)
func main() {
// Create loggerFactory with level Error above
loggerFactory := logger.NewLoggerFactory(logger.ErrorLevel)
// fake context,
// in real cases, it should be current app's context
ctx := context.TODO()
// withField will be filled into "content" field
loggerFactory.Logger(ctx).WithField("test key", "test").Alert("Test")
// simple log, no content field
loggerFactory.Logger(ctx).Debug("Testing")
loggerFactory.Logger(ctx).Critical("Testing")
loggerFactory.Logger(ctx).Error("Testing")
loggerFactory.Logger(ctx).Warning("Testing")
loggerFactory.Logger(ctx).Notice("Testing")
}
Without content field
package main
import (
"bitbucket.org/snapmartinc/logger"
"context"
)
func main() {
// Create loggerFactory with level Error above
loggerFactory := logger.NewLoggerFactory(logger.ErrorLevel)
// fake context,
// in real cases, it should be current app's context
ctx := context.TODO()
// simple log, no content field
loggerFactory.Logger(ctx).Debug("Testing")
loggerFactory.Logger(ctx).Critical("Testing")
loggerFactory.Logger(ctx).Error("Testing")
loggerFactory.Logger(ctx).Warning("Testing")
loggerFactory.Logger(ctx).Notice("Testing")
}
simple log without any fields
package main
import (
"bitbucket.org/snapmartinc/logger"
)
func main() {
logger.Info("Test log")
}