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
9775e3e3
Commit
9775e3e3
authored
Jul 16, 2015
by
astaxie
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1265 from fugr/develop
set DoRotate fname like xx.2013-01-01.2.log
parents
160d82d1
59b903d5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
2 deletions
+7
-2
file.go
logs/file.go
+7
-2
No files found.
logs/file.go
View file @
9775e3e3
...
...
@@ -205,15 +205,20 @@ func (w *FileLogWriter) lines() (int, error) {
}
// DoRotate means it need to write file in new file.
// new file name like xx.
log.2013-01-01.2
// new file name like xx.
2013-01-01.2.log
func
(
w
*
FileLogWriter
)
DoRotate
()
error
{
_
,
err
:=
os
.
Lstat
(
w
.
Filename
)
if
err
==
nil
{
// file exists
// Find the next available number
num
:=
1
fname
:=
""
suffix
:=
filepath
.
Ext
(
w
.
Filename
)
filenameOnly
:=
strings
.
TrimSuffix
(
w
.
Filename
,
suffix
)
if
suffix
==
""
{
suffix
=
".log"
}
for
;
err
==
nil
&&
num
<=
999
;
num
++
{
fname
=
w
.
Filename
+
fmt
.
Sprintf
(
".%s.%03d"
,
time
.
Now
()
.
Format
(
"2006-01-02"
),
num
)
fname
=
filenameOnly
+
fmt
.
Sprintf
(
".%s.%03d%s"
,
time
.
Now
()
.
Format
(
"2006-01-02"
),
num
,
suffix
)
_
,
err
=
os
.
Lstat
(
fname
)
}
// return error if the last file checked still existed
...
...
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