-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Enable `zap` logger Signed-off-by: Arrobo, Gabriel <[email protected]> * Create minor release Signed-off-by: Arrobo, Gabriel <[email protected]> --------- Signed-off-by: Arrobo, Gabriel <[email protected]>
- Loading branch information
1 parent
340d1e7
commit 9e250ff
Showing
6 changed files
with
213 additions
and
247 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
1.4.2-dev | ||
1.5.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// SPDX-FileCopyrightText: 2024 Intel Corporation | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package logger | ||
|
||
import ( | ||
"go.uber.org/zap" | ||
"go.uber.org/zap/zapcore" | ||
) | ||
|
||
var ( | ||
log *zap.Logger | ||
SimappLog *zap.SugaredLogger | ||
atomicLevel zap.AtomicLevel | ||
) | ||
|
||
func init() { | ||
atomicLevel = zap.NewAtomicLevelAt(zap.InfoLevel) | ||
config := zap.Config{ | ||
Level: atomicLevel, | ||
Development: false, | ||
Encoding: "console", | ||
EncoderConfig: zap.NewProductionEncoderConfig(), | ||
OutputPaths: []string{"stdout"}, | ||
ErrorOutputPaths: []string{"stderr"}, | ||
} | ||
|
||
config.EncoderConfig.TimeKey = "timestamp" | ||
config.EncoderConfig.EncodeTime = zapcore.ISO8601TimeEncoder | ||
config.EncoderConfig.LevelKey = "level" | ||
config.EncoderConfig.EncodeLevel = zapcore.CapitalLevelEncoder | ||
config.EncoderConfig.CallerKey = "caller" | ||
config.EncoderConfig.EncodeCaller = zapcore.ShortCallerEncoder | ||
config.EncoderConfig.MessageKey = "message" | ||
config.EncoderConfig.StacktraceKey = "" | ||
|
||
var err error | ||
log, err = config.Build() | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
SimappLog = log.Sugar() | ||
} | ||
|
||
func GetLogger() *zap.Logger { | ||
return log | ||
} | ||
|
||
// SetLogLevel: set the log level (panic|fatal|error|warn|info|debug) | ||
func SetLogLevel(level zapcore.Level) { | ||
SimappLog.Infoln("set log level:", level) | ||
atomicLevel.SetLevel(level) | ||
} |
Oops, something went wrong.