Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
beego
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
beego
Commits
a0434323
Commit
a0434323
authored
Jan 28, 2016
by
Pelle Johnsen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change option name from noColor to color
Still same default behavior (with color)
parent
7f888e3d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
5 deletions
+6
-5
console.go
logs/console.go
+5
-4
console_test.go
logs/console_test.go
+1
-1
No files found.
logs/console.go
View file @
a0434323
...
...
@@ -47,9 +47,9 @@ var colors = []brush{
// consoleWriter implements LoggerInterface and writes messages to terminal.
type
consoleWriter
struct
{
lg
*
log
.
Logger
Level
int
`json:"level"`
NoColor
bool
`json:"noC
olor"`
lg
*
log
.
Logger
Level
int
`json:"level"`
Color
bool
`json:"c
olor"`
}
// NewConsole create ConsoleWriter returning as LoggerInterface.
...
...
@@ -57,6 +57,7 @@ func NewConsole() Logger {
cw
:=
&
consoleWriter
{
lg
:
log
.
New
(
os
.
Stdout
,
""
,
0
),
Level
:
LevelDebug
,
Color
:
true
,
}
return
cw
}
...
...
@@ -76,7 +77,7 @@ func (c *consoleWriter) WriteMsg(when time.Time, msg string, level int) error {
return
nil
}
msg
=
formatLogTime
(
when
)
+
msg
if
runtime
.
GOOS
==
"windows"
||
c
.
No
Color
{
if
runtime
.
GOOS
==
"windows"
||
!
c
.
Color
{
c
.
lg
.
Println
(
msg
)
return
nil
}
...
...
logs/console_test.go
View file @
a0434323
...
...
@@ -46,6 +46,6 @@ func TestConsole(t *testing.T) {
// Test console without color
func
TestConsoleNoColor
(
t
*
testing
.
T
)
{
log
:=
NewLogger
(
100
)
log
.
SetLogger
(
"console"
,
`{"
noColor":tru
e}`
)
log
.
SetLogger
(
"console"
,
`{"
color":fals
e}`
)
testConsoleCalls
(
log
)
}
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