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
1edb13d7
Commit
1edb13d7
authored
Apr 19, 2015
by
Torkel Odegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed gofmt formating
parent
aa8beda4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
30 deletions
+26
-30
pkg/setting/setting.go
+26
-30
No files found.
pkg/setting/setting.go
View file @
1edb13d7
...
...
@@ -5,11 +5,11 @@ package setting
import
(
"bytes"
"encoding/json"
"fmt"
"net/url"
"os"
"path"
"encoding/json"
"path/filepath"
"regexp"
"runtime"
...
...
@@ -54,7 +54,7 @@ var (
// Log settings.
LogModes
[]
string
LogConfigs
[]
string
LogConfigs
[]
util
.
DynMap
// Http server options
Protocol
Scheme
...
...
@@ -420,7 +420,7 @@ func initLogging(args *CommandLineArgs) {
LogModes
=
strings
.
Split
(
Cfg
.
Section
(
"log"
)
.
Key
(
"mode"
)
.
MustString
(
"console"
),
","
)
LogsPath
=
makeAbsolute
(
Cfg
.
Section
(
"paths"
)
.
Key
(
"logs"
)
.
String
(),
HomePath
)
LogConfigs
=
make
([]
string
,
len
(
LogModes
))
LogConfigs
=
make
([]
util
.
DynMap
,
len
(
LogModes
))
for
i
,
mode
:=
range
LogModes
{
mode
=
strings
.
TrimSpace
(
mode
)
sec
,
err
:=
Cfg
.
GetSection
(
"log."
+
mode
)
...
...
@@ -436,53 +436,49 @@ func initLogging(args *CommandLineArgs) {
log
.
Fatal
(
4
,
"Unknown log level: %s"
,
levelName
)
}
var
logCfg
util
.
DynMap
// Generate log configuration.
switch
mode
{
case
"console"
:
logCfg
=
util
.
DynMap
{
"level"
:
level
}
LogConfigs
[
i
]
=
util
.
DynMap
{
"level"
:
level
}
case
"file"
:
logPath
:=
sec
.
Key
(
"file_name"
)
.
MustString
(
filepath
.
Join
(
LogsPath
,
"grafana.log"
))
os
.
MkdirAll
(
filepath
.
Dir
(
logPath
),
os
.
ModePerm
)
logCfg
=
util
.
DynMap
{
"level"
:
level
,
LogConfigs
[
i
]
=
util
.
DynMap
{
"level"
:
level
,
"filename"
:
logPath
,
"rotate"
:
sec
.
Key
(
"log_rotate"
)
.
MustBool
(
true
),
"rotate"
:
sec
.
Key
(
"log_rotate"
)
.
MustBool
(
true
),
"maxlines"
:
sec
.
Key
(
"max_lines"
)
.
MustInt
(
1000000
),
"maxsize"
:
1
<<
uint
(
sec
.
Key
(
"max_size_shift"
)
.
MustInt
(
28
)),
"daily"
:
sec
.
Key
(
"daily_rotate"
)
.
MustBool
(
true
),
"maxdays"
:
sec
.
Key
(
"max_days"
)
.
MustInt
(
7
),
"maxsize"
:
1
<<
uint
(
sec
.
Key
(
"max_size_shift"
)
.
MustInt
(
28
)),
"daily"
:
sec
.
Key
(
"daily_rotate"
)
.
MustBool
(
true
),
"maxdays"
:
sec
.
Key
(
"max_days"
)
.
MustInt
(
7
),
}
case
"conn"
:
logCfg
=
util
.
DynMap
{
"level"
:
level
,
LogConfigs
[
i
]
=
util
.
DynMap
{
"level"
:
level
,
"reconnectOnMsg"
:
sec
.
Key
(
"reconnect_on_msg"
)
.
MustBool
(),
"reconnect"
:
sec
.
Key
(
"reconnect"
)
.
MustBool
(),
"net"
:
sec
.
Key
(
"protocol"
)
.
In
(
"tcp"
,
[]
string
{
"tcp"
,
"unix"
,
"udp"
}),
"addr"
:
sec
.
Key
(
"addr"
)
.
MustString
(
":7020"
),
"reconnect"
:
sec
.
Key
(
"reconnect"
)
.
MustBool
(),
"net"
:
sec
.
Key
(
"protocol"
)
.
In
(
"tcp"
,
[]
string
{
"tcp"
,
"unix"
,
"udp"
}),
"addr"
:
sec
.
Key
(
"addr"
)
.
MustString
(
":7020"
),
}
case
"smtp"
:
logCfg
=
util
.
DynMap
{
"level"
:
level
,
"user"
:
sec
.
Key
(
"user"
)
.
MustString
(
"example@example.com"
),
"passwd"
:
sec
.
Key
(
"passwd"
)
.
MustString
(
"******"
),
"host"
:
sec
.
Key
(
"host"
)
.
MustString
(
"127.0.0.1:25"
),
LogConfigs
[
i
]
=
util
.
DynMap
{
"level"
:
level
,
"user"
:
sec
.
Key
(
"user"
)
.
MustString
(
"example@example.com"
),
"passwd"
:
sec
.
Key
(
"passwd"
)
.
MustString
(
"******"
),
"host"
:
sec
.
Key
(
"host"
)
.
MustString
(
"127.0.0.1:25"
),
"receivers"
:
sec
.
Key
(
"receivers"
)
.
MustString
(
"[]"
),
"subject"
:
sec
.
Key
(
"subject"
)
.
MustString
(
"Diagnostic message from serve"
),
"subject"
:
sec
.
Key
(
"subject"
)
.
MustString
(
"Diagnostic message from serve"
),
}
case
"database"
:
logCfg
=
util
.
DynMap
{
"level"
:
level
,
LogConfigs
[
i
]
=
util
.
DynMap
{
"level"
:
level
,
"driver"
:
sec
.
Key
(
"driver"
)
.
String
(),
"conn"
:
sec
.
Key
(
"conn"
)
.
String
(),
"conn"
:
sec
.
Key
(
"conn"
)
.
String
(),
}
}
cfgJsonBytes
,
_
:=
json
.
Marshal
(
logCfg
)
LogConfigs
[
i
]
=
string
(
cfgJsonBytes
)
fmt
.
Printf
(
"Config: %s
\n
"
,
LogConfigs
[
i
])
log
.
NewLogger
(
Cfg
.
Section
(
"log"
)
.
Key
(
"buffer_len"
)
.
MustInt64
(
10000
),
mode
,
LogConfigs
[
i
])
cfgJsonBytes
,
_
:=
json
.
Marshal
(
LogConfigs
[
i
])
log
.
NewLogger
(
Cfg
.
Section
(
"log"
)
.
Key
(
"buffer_len"
)
.
MustInt64
(
10000
),
mode
,
string
(
cfgJsonBytes
))
}
}
...
...
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