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
bed1d9bd
Commit
bed1d9bd
authored
Aug 17, 2016
by
astaxie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update the performance
parent
44a57e86
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
6 deletions
+48
-6
logger.go
logs/logger.go
+46
-3
logger_test.go
logs/logger_test.go
+2
-3
No files found.
logs/logger.go
View file @
bed1d9bd
...
...
@@ -72,10 +72,53 @@ func NewModeAnsiColorWriter(w io.Writer, mode outputMode) io.Writer {
return
w
}
const
(
y1
=
`0123456789`
y2
=
`0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789`
y3
=
`0000000000111111111122222222223333333333444444444455555555556666666666777777777788888888889999999999`
y4
=
`0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789`
mo1
=
`000000000111`
mo2
=
`123456789012`
d1
=
`0000000001111111111222222222233`
d2
=
`1234567890123456789012345678901`
h1
=
`000000000011111111112222`
h2
=
`012345678901234567890123`
mi1
=
`000000000011111111112222222222333333333344444444445555555555`
mi2
=
`012345678901234567890123456789012345678901234567890123456789`
s1
=
`000000000011111111112222222222333333333344444444445555555555`
s2
=
`012345678901234567890123456789012345678901234567890123456789`
)
func
formatTimeHeader
(
when
time
.
Time
)
([]
byte
,
int
)
{
_
,
_
,
d
:=
when
.
Date
()
s
:=
when
.
Format
(
"2006/01/02 15:04:05 "
)
return
[]
byte
(
s
),
d
y
,
mo
,
d
:=
when
.
Date
()
h
,
mi
,
s
:=
when
.
Clock
()
//len("2006/01/02 15:04:05 ")==20
var
buf
[
20
]
byte
//change to '3' after 984 years, LOL
buf
[
0
]
=
y1
[
y
/
1000
%
10
]
//change to '1' after 84 years, LOL
buf
[
1
]
=
y2
[
y
/
100
]
buf
[
2
]
=
y3
[
y
-
y
/
100
*
100
]
buf
[
3
]
=
y4
[
y
-
y
/
100
*
100
]
buf
[
4
]
=
'/'
buf
[
5
]
=
mo1
[
mo
-
1
]
buf
[
6
]
=
mo2
[
mo
-
1
]
buf
[
7
]
=
'/'
buf
[
8
]
=
d1
[
d
-
1
]
buf
[
9
]
=
d2
[
d
-
1
]
buf
[
10
]
=
' '
buf
[
11
]
=
h1
[
h
]
buf
[
12
]
=
h2
[
h
]
buf
[
13
]
=
':'
buf
[
14
]
=
mi1
[
mi
]
buf
[
15
]
=
mi2
[
mi
]
buf
[
16
]
=
':'
buf
[
17
]
=
s1
[
s
]
buf
[
18
]
=
s2
[
s
]
buf
[
19
]
=
' '
return
buf
[
0
:
],
d
}
var
(
...
...
logs/logger_test.go
View file @
bed1d9bd
...
...
@@ -15,9 +15,9 @@
package
logs
import
(
"bytes"
"testing"
"time"
"bytes"
)
func
TestFormatHeader_0
(
t
*
testing
.
T
)
{
...
...
@@ -72,4 +72,4 @@ func TestNewAnsiColor2(t *testing.T) {
if
w1
!=
w2
{
t
.
Errorf
(
"Get %#v, want %#v"
,
w1
,
w2
)
}
}
\ No newline at end of file
}
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