Skip to content

Commit e427018

Browse files
committed
added dev log level
1 parent f81251e commit e427018

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

.github/templates/README.template.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ To change the Log Level set `logLevel` to: (default: `info`)
284284
| `warn` |
285285
| `error` |
286286
| `fatal` |
287+
| `dev` |
287288

288289
## Contributing
289290

utils/config/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,8 @@ func Load() {
129129

130130
log.Info("Finished Loading Configuration")
131131

132-
log.Debug(utils.ToJson(config.All()))
133-
log.Debug(utils.ToJson(ENV))
132+
log.Dev(utils.ToJson(config.All()))
133+
log.Dev(utils.ToJson(ENV))
134134
}
135135

136136
func LoadFile(path string, config *koanf.Koanf, parser koanf.Parser) (koanf.Provider, error) {

utils/logger/logger.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@ import (
99
)
1010

1111
var _log *zap.Logger
12+
var _logLevel = ""
1213

1314
func Init(level string) {
14-
logLevel := getLogLevel(level)
15+
_logLevel = strings.ToLower(level)
16+
17+
logLevel := getLogLevel(_logLevel)
1518

1619
cfg := zap.Config{
1720
Level: zap.NewAtomicLevelAt(logLevel),
@@ -47,13 +50,13 @@ func Init(level string) {
4750
}
4851

4952
func getLogLevel(level string) zapcore.Level {
50-
level = strings.ToLower(level)
51-
5253
switch level {
5354
case "info":
5455
return zapcore.InfoLevel
5556
case "debug":
5657
return zapcore.DebugLevel
58+
case "dev":
59+
return zapcore.DebugLevel
5760
case "warn":
5861
return zapcore.WarnLevel
5962
case "error":
@@ -73,6 +76,12 @@ func Debug(msg ...string) {
7376
_log.Debug(strings.Join(msg, ""))
7477
}
7578

79+
func Dev(msg ...string) {
80+
if _logLevel == "dev" {
81+
_log.Debug(strings.Join(msg, ""))
82+
}
83+
}
84+
7685
func Error(msg ...string) {
7786
_log.Error(strings.Join(msg, ""))
7887
}

0 commit comments

Comments
 (0)