forked from bluesky-social/indigo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SetIpfsWriter, GOLOG_* env to BSKYLOG_*
- Loading branch information
1 parent
049cb56
commit 11fff12
Showing
2 changed files
with
81 additions
and
16 deletions.
There are no files selected for viewing
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,35 @@ | ||
package cliutil | ||
|
||
import ( | ||
"io" | ||
|
||
ipfslog "github.com/ipfs/go-log/v2" | ||
"go.uber.org/zap/zapcore" | ||
) | ||
|
||
func SetIpfsWriter(out io.Writer, format string, level string) { | ||
var ze zapcore.Encoder | ||
switch format { | ||
case "json": | ||
ze = zapcore.NewJSONEncoder(zapcore.EncoderConfig{}) | ||
case "text": | ||
ze = zapcore.NewConsoleEncoder(zapcore.EncoderConfig{}) | ||
default: | ||
ze = zapcore.NewConsoleEncoder(zapcore.EncoderConfig{}) | ||
} | ||
var zl zapcore.LevelEnabler | ||
switch level { | ||
case "debug": | ||
zl = zapcore.DebugLevel | ||
case "info": | ||
zl = zapcore.InfoLevel | ||
case "warn": | ||
zl = zapcore.WarnLevel | ||
case "error": | ||
zl = zapcore.ErrorLevel | ||
default: | ||
zl = zapcore.InfoLevel | ||
} | ||
nc := zapcore.NewCore(ze, zapcore.AddSync(out), zl) | ||
ipfslog.SetPrimaryCore(nc) | ||
} |
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