1
0
mirror of https://github.com/khorevaa/logos.git synced 2025-04-02 22:25:31 +02:00
logos/example_test.go

67 lines
1.2 KiB
Go
Raw Normal View History

2021-02-01 17:50:15 +03:00
package logos_test
import (
2021-02-01 18:47:45 +03:00
"errors"
2021-02-01 17:50:15 +03:00
"github.com/khorevaa/logos"
)
2021-02-01 18:47:45 +03:00
func ExampleNew_simple() {
2021-02-01 17:50:15 +03:00
2021-02-01 18:47:45 +03:00
log := logos.New("<your-package-name>") // like github.com/khorevaa/logos
log.Info("This is me first log. Hello world logging systems")
2021-02-01 17:50:15 +03:00
2021-02-01 18:47:45 +03:00
}
func ExampleNew_with_config_json() {
rawConfig := `
appenders:
console:
- name: CONSOLE
target: stdout
encoder:
json:
loggerConfigs:
root:
level: info
appender_refs:
- CONSOLE
`
logos.InitWithConfigContent(rawConfig)
log := logos.New("<your-package-name>") // like github.com/khorevaa/logos
log.Info("This is me first log. Hello world logging systems")
}
func ExampleNew_with_color_scheme() {
rawConfig := `
appenders:
console:
- name: CONSOLE
target: stdout
encoder:
console:
color_scheme:
info_level: blue+b
debug_level: green+b
loggerConfigs:
root:
level: debug
appender_refs:
- CONSOLE
`
logos.InitWithConfigContent(rawConfig)
log := logos.New("<your-package-name>") // like github.com/khorevaa/logos
log.Info("This is me first log. Hello world logging systems")
err := errors.New("log system error")
log.Debug("This is me first error", logos.Any("err", err))
2021-02-01 17:50:15 +03:00
}