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
d37e18fd
Commit
d37e18fd
authored
Oct 01, 2015
by
ctdk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add config option to strip (most) colors from console logs
parent
7dc923a2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
7 deletions
+15
-7
conf/defaults.ini
+2
-0
pkg/log/console.go
+7
-5
pkg/setting/setting.go
+6
-2
No files found.
conf/defaults.ini
View file @
d37e18fd
...
@@ -224,6 +224,8 @@ level = Info
...
@@ -224,6 +224,8 @@ level = Info
# For "console" mode only
# For "console" mode only
[log.console]
[log.console]
level
=
level
=
# Set formatting to "false" to disable color formatting of console logs
formatting
=
true
# For "file" mode only
# For "file" mode only
[log.file]
[log.file]
...
...
pkg/log/console.go
View file @
d37e18fd
...
@@ -45,15 +45,17 @@ var (
...
@@ -45,15 +45,17 @@ var (
// ConsoleWriter implements LoggerInterface and writes messages to terminal.
// ConsoleWriter implements LoggerInterface and writes messages to terminal.
type
ConsoleWriter
struct
{
type
ConsoleWriter
struct
{
lg
*
log
.
Logger
lg
*
log
.
Logger
Level
int
`json:"level"`
Level
int
`json:"level"`
Formatting
bool
`json:"formatting"`
}
}
// create ConsoleWriter returning as LoggerInterface.
// create ConsoleWriter returning as LoggerInterface.
func
NewConsole
()
LoggerInterface
{
func
NewConsole
()
LoggerInterface
{
return
&
ConsoleWriter
{
return
&
ConsoleWriter
{
lg
:
log
.
New
(
os
.
Stderr
,
""
,
log
.
Ldate
|
log
.
Ltime
),
lg
:
log
.
New
(
os
.
Stderr
,
""
,
log
.
Ldate
|
log
.
Ltime
),
Level
:
TRACE
,
Level
:
TRACE
,
Formatting
:
true
,
}
}
}
}
...
@@ -65,7 +67,7 @@ func (cw *ConsoleWriter) WriteMsg(msg string, skip, level int) error {
...
@@ -65,7 +67,7 @@ func (cw *ConsoleWriter) WriteMsg(msg string, skip, level int) error {
if
cw
.
Level
>
level
{
if
cw
.
Level
>
level
{
return
nil
return
nil
}
}
if
runtime
.
GOOS
==
"windows"
{
if
runtime
.
GOOS
==
"windows"
||
!
cw
.
Formatting
{
cw
.
lg
.
Println
(
msg
)
cw
.
lg
.
Println
(
msg
)
}
else
{
}
else
{
cw
.
lg
.
Println
(
colors
[
level
](
msg
))
cw
.
lg
.
Println
(
colors
[
level
](
msg
))
...
...
pkg/setting/setting.go
View file @
d37e18fd
...
@@ -140,7 +140,7 @@ type CommandLineArgs struct {
...
@@ -140,7 +140,7 @@ type CommandLineArgs struct {
func
init
()
{
func
init
()
{
IsWindows
=
runtime
.
GOOS
==
"windows"
IsWindows
=
runtime
.
GOOS
==
"windows"
log
.
NewLogger
(
0
,
"console"
,
`{"level": 0}`
)
log
.
NewLogger
(
0
,
"console"
,
`{"level": 0
, "formatting":true
}`
)
}
}
func
parseAppUrlAndSubUrl
(
section
*
ini
.
Section
)
(
string
,
string
)
{
func
parseAppUrlAndSubUrl
(
section
*
ini
.
Section
)
(
string
,
string
)
{
...
@@ -527,7 +527,11 @@ func initLogging(args *CommandLineArgs) {
...
@@ -527,7 +527,11 @@ func initLogging(args *CommandLineArgs) {
// Generate log configuration.
// Generate log configuration.
switch
mode
{
switch
mode
{
case
"console"
:
case
"console"
:
LogConfigs
[
i
]
=
util
.
DynMap
{
"level"
:
level
}
formatting
:=
sec
.
Key
(
"formatting"
)
.
MustBool
(
true
)
LogConfigs
[
i
]
=
util
.
DynMap
{
"level"
:
level
,
"formatting"
:
formatting
,
}
case
"file"
:
case
"file"
:
logPath
:=
sec
.
Key
(
"file_name"
)
.
MustString
(
filepath
.
Join
(
LogsPath
,
"grafana.log"
))
logPath
:=
sec
.
Key
(
"file_name"
)
.
MustString
(
filepath
.
Join
(
LogsPath
,
"grafana.log"
))
os
.
MkdirAll
(
filepath
.
Dir
(
logPath
),
os
.
ModePerm
)
os
.
MkdirAll
(
filepath
.
Dir
(
logPath
),
os
.
ModePerm
)
...
...
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