Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
client
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elixxir
client
Merge requests
!693
Change log level to match bindings
Code
Review changes
Check out branch
Download
Patches
Plain diff
Open
Change log level to match bindings
xx-4717/logLevel
into
release
Overview
0
Commits
1
Pipelines
0
Changes
1
Open
Jonah Husson
requested to merge
xx-4717/logLevel
into
release
1 year ago
Overview
0
Commits
1
Pipelines
0
Changes
1
Expand
0
0
Merge request reports
Compare
release
release (HEAD)
and
latest version
latest version
3740295d
1 commit,
1 year ago
1 file
+
27
−
16
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
cmd/root.go
+
27
−
16
Options
@@ -911,7 +911,7 @@ func getUIDFromString(idStr string) *id.ID {
return
ID
}
func
initLog
(
threshold
uint
,
logPath
string
)
{
func
initLog
(
level
uint
,
logPath
string
)
{
if
logPath
!=
"-"
&&
logPath
!=
""
{
// Disable stdout output
jww
.
SetStdoutOutput
(
ioutil
.
Discard
)
@@ -924,20 +924,30 @@ func initLog(threshold uint, logPath string) {
jww
.
SetLogOutput
(
logOutput
)
}
if
threshold
>
1
{
jww
.
SetStdoutThreshold
(
jww
.
LevelTrace
)
jww
.
SetLogThreshold
(
jww
.
LevelTrace
)
jww
.
SetFlags
(
log
.
LstdFlags
|
log
.
Lmicroseconds
)
jww
.
INFO
.
Printf
(
"log level set to: TRACE"
)
}
else
if
threshold
==
1
{
jww
.
SetStdoutThreshold
(
jww
.
LevelDebug
)
jww
.
SetLogThreshold
(
jww
.
LevelDebug
)
jww
.
SetFlags
(
log
.
LstdFlags
|
log
.
Lmicroseconds
)
jww
.
INFO
.
Printf
(
"log level set to: DEBUG"
)
}
else
{
jww
.
SetStdoutThreshold
(
jww
.
LevelInfo
)
jww
.
SetLogThreshold
(
jww
.
LevelInfo
)
jww
.
INFO
.
Printf
(
"log level set to: INFO"
)
if
level
<
0
||
level
>
6
{
jww
.
FATAL
.
Panicf
(
"log level is not valid: log level: %d"
,
level
)
}
threshold
:=
jww
.
Threshold
(
level
)
jww
.
SetLogThreshold
(
threshold
)
jww
.
SetStdoutThreshold
(
threshold
)
jww
.
SetFlags
(
log
.
LstdFlags
|
log
.
Lmicroseconds
)
switch
threshold
{
case
jww
.
LevelTrace
:
fallthrough
case
jww
.
LevelDebug
:
fallthrough
case
jww
.
LevelInfo
:
jww
.
INFO
.
Printf
(
"Log level set to: %s"
,
threshold
)
case
jww
.
LevelWarn
:
jww
.
WARN
.
Printf
(
"Log level set to: %s"
,
threshold
)
case
jww
.
LevelError
:
jww
.
ERROR
.
Printf
(
"Log level set to: %s"
,
threshold
)
case
jww
.
LevelCritical
:
jww
.
CRITICAL
.
Printf
(
"Log level set to: %s"
,
threshold
)
case
jww
.
LevelFatal
:
jww
.
FATAL
.
Printf
(
"Log level set to: %s"
,
threshold
)
}
if
viper
.
GetBool
(
verboseRoundTrackingFlag
)
{
@@ -993,7 +1003,8 @@ func init() {
// Cobra supports persistent flags, which, if defined here,
// will be global for your application.
rootCmd
.
PersistentFlags
()
.
UintP
(
logLevelFlag
,
"v"
,
0
,
"Verbose mode for debugging"
)
"Determine logging threshold, from 0 -> 6. Starting at 0, "
+
"the log levels are TRACE, DEBUG, INFO, WARN, ERROR, CRITICAL, FATAL"
)
viper
.
BindPFlag
(
logLevelFlag
,
rootCmd
.
PersistentFlags
()
.
Lookup
(
logLevelFlag
))
Loading