MCPcopy Create free account
hub / github.com/encodeous/nylon / NewLogger

Function NewLogger

polyamide/device/logger.go:36–48  ·  view source on GitHub ↗

NewLogger constructs a Logger that writes to stdout. It logs at the specified Log level and above. It decorates Log lines with the Log level, date, time, and prepend.

(level int, prepend string)

Source from the content-addressed store, hash-verified

34// It logs at the specified Log level and above.
35// It decorates Log lines with the Log level, date, time, and prepend.
36func NewLogger(level int, prepend string) *Logger {
37 logger := &Logger{DiscardLogf, DiscardLogf}
38 logf := func(prefix string) func(string, ...any) {
39 return log.New(os.Stdout, prefix+": "+prepend, log.Ldate|log.Ltime).Printf
40 }
41 if level >= LogLevelVerbose {
42 logger.Verbosef = logf("DEBUG")
43 }
44 if level >= LogLevelError {
45 logger.Errorf = logf("ERROR")
46 }
47 return logger
48}

Callers 5

mainFunction · 0.92
mainFunction · 0.92
mainFunction · 0.92
genTestPairFunction · 0.85
randDeviceFunction · 0.85

Calls

no outgoing calls

Tested by 2

genTestPairFunction · 0.68
randDeviceFunction · 0.68