Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
d474eba5
Commit
d474eba5
authored
May 18, 2016
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(logging): fixed reading config level from config file, fixes #5079
parent
cd80884b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
6 deletions
+16
-6
pkg/setting/setting.go
+16
-6
No files found.
pkg/setting/setting.go
View file @
d474eba5
...
...
@@ -526,6 +526,17 @@ var logLevels = map[string]int{
"Critical"
:
5
,
}
func
getLogLevel
(
key
string
,
defaultName
string
)
(
string
,
int
)
{
levelName
:=
Cfg
.
Section
(
key
)
.
Key
(
"level"
)
.
In
(
defaultName
,
[]
string
{
"Trace"
,
"Debug"
,
"Info"
,
"Warn"
,
"Error"
,
"Critical"
})
level
,
ok
:=
logLevels
[
levelName
]
if
!
ok
{
log
.
Fatal
(
4
,
"Unknown log level: %s"
,
levelName
)
}
return
levelName
,
level
}
func
initLogging
(
args
*
CommandLineArgs
)
{
//close any existing log handlers.
log
.
Close
()
...
...
@@ -533,8 +544,12 @@ func initLogging(args *CommandLineArgs) {
LogModes
=
strings
.
Split
(
Cfg
.
Section
(
"log"
)
.
Key
(
"mode"
)
.
MustString
(
"console"
),
","
)
LogsPath
=
makeAbsolute
(
Cfg
.
Section
(
"paths"
)
.
Key
(
"logs"
)
.
String
(),
HomePath
)
defaultLevelName
,
_
:=
getLogLevel
(
"log"
,
"Info"
)
LogConfigs
=
make
([]
util
.
DynMap
,
len
(
LogModes
))
for
i
,
mode
:=
range
LogModes
{
mode
=
strings
.
TrimSpace
(
mode
)
sec
,
err
:=
Cfg
.
GetSection
(
"log."
+
mode
)
if
err
!=
nil
{
...
...
@@ -542,12 +557,7 @@ func initLogging(args *CommandLineArgs) {
}
// Log level.
levelName
:=
Cfg
.
Section
(
"log."
+
mode
)
.
Key
(
"level"
)
.
In
(
"Trace"
,
[]
string
{
"Trace"
,
"Debug"
,
"Info"
,
"Warn"
,
"Error"
,
"Critical"
})
level
,
ok
:=
logLevels
[
levelName
]
if
!
ok
{
log
.
Fatal
(
4
,
"Unknown log level: %s"
,
levelName
)
}
_
,
level
:=
getLogLevel
(
"log."
+
mode
,
defaultLevelName
)
// Generate log configuration.
switch
mode
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment