add bracket format (#15)
All checks were successful
continuous-integration/drone/tag Build is passing
continuous-integration/drone/push Build is passing

Reviewed-on: #15
Co-authored-by: andrey <andrey@4devs.io>
Co-committed-by: andrey <andrey@4devs.io>
This commit was merged in pull request #15.
This commit is contained in:
2024-01-03 21:35:21 +03:00
parent acaa46b73f
commit 57a908f894
11 changed files with 128 additions and 83 deletions

View File

@@ -2,6 +2,7 @@ package main
import (
"context"
"time"
"gitoa.ru/go-4devs/log"
"gitoa.ru/go-4devs/log/field"
@@ -16,9 +17,13 @@ func main() {
log.Err(ctx, "error message", 42)
service(ctx, log.Log())
logger := log.New(log.WithJSONFormat()).With(log.WithSource(10, log.TrimPath))
logger := log.New(log.WithJSONFormat()).With(log.WithSource(10, log.TrimPath), log.WithTime(log.KeyTime, time.RFC3339))
logger.AlertKV(ctx, "alert message new logger", field.String("string", "value"))
service(ctx, logger)
strLogger := log.New(log.WithFormat(log.FormatWithBracket())).With(log.WithSource(10, log.TrimPath), log.WithTime(log.KeyTime, time.RFC3339))
strLogger.AlertKV(ctx, "alert message new txt logger", field.String("string", "value"))
service(ctx, strLogger)
}
func service(ctx context.Context, logger log.Logger) {