cloudflare/pint

Public

mirrored from https://github.com/cloudflare/pintAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v0.1.3

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

cmd/pint/logger.go

39lines · modecode

1package main
2
3import (
4 "fmt"
5 "os"
6
7 "github.com/rs/zerolog"
8 "github.com/rs/zerolog/log"
9)
10
11func msgFormatter(msg interface{}) string {
12 return fmt.Sprintf("msg=%q", msg)
13}
14func lvlFormatter(level interface{}) string {
15 if level == nil {
16 return ""
17 }
18 return fmt.Sprintf("level=%s", level)
19}
20
21func initLogger(level string) error {
22 log.Logger = log.Logger.Output(zerolog.ConsoleWriter{
23 Out: os.Stderr,
24 NoColor: false,
25 FormatLevel: lvlFormatter,
26 FormatMessage: msgFormatter,
27 FormatTimestamp: func(interface{}) string {
28 return ""
29 },
30 })
31
32 l, err := zerolog.ParseLevel(level)
33 if err != nil {
34 return err
35 }
36 zerolog.SetGlobalLevel(l)
37
38 return nil
39}
40