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
11e6c282
Commit
11e6c282
authored
Jan 21, 2014
by
cloudaice
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
diffrent level logs display diffrent color
parent
91d75e89
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
1 deletion
+20
-1
console.go
logs/console.go
+20
-1
No files found.
logs/console.go
View file @
11e6c282
...
...
@@ -6,6 +6,25 @@ import (
"os"
)
type
Brush
func
(
string
)
string
func
NewBrush
(
color
string
)
Brush
{
pre
:=
"
\0
33["
reset
:=
"
\0
33[0m"
return
func
(
text
string
)
string
{
return
pre
+
color
+
"m"
+
text
+
reset
}
}
var
colors
=
[]
Brush
{
NewBrush
(
"1;36"
),
// Trace cyan
NewBrush
(
"1;34"
),
// Debug blue
NewBrush
(
"1;32"
),
// Info green
NewBrush
(
"1;33"
),
// Warn yellow
NewBrush
(
"1;31"
),
// Error red
NewBrush
(
"1;35"
),
// Critical purple
}
// ConsoleWriter implements LoggerInterface and writes messages to terminal.
type
ConsoleWriter
struct
{
lg
*
log
.
Logger
...
...
@@ -35,7 +54,7 @@ func (c *ConsoleWriter) WriteMsg(msg string, level int) error {
if
level
<
c
.
Level
{
return
nil
}
c
.
lg
.
Println
(
msg
)
c
.
lg
.
Println
(
colors
[
level
](
msg
)
)
return
nil
}
...
...
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