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
221306ff
Commit
221306ff
authored
Mar 29, 2016
by
JessonChan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
file rotate bug
parent
699de2ae
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
10 deletions
+7
-10
file.go
logs/file.go
+7
-10
No files found.
logs/file.go
View file @
221306ff
...
...
@@ -60,14 +60,11 @@ type fileLogWriter struct {
// newFileWriter create a FileLogWriter returning as LoggerInterface.
func
newFileWriter
()
Logger
{
w
:=
&
fileLogWriter
{
Filename
:
""
,
MaxLines
:
1000000
,
MaxSize
:
1
<<
28
,
//256 MB
Daily
:
true
,
MaxDays
:
7
,
Rotate
:
true
,
Level
:
LevelTrace
,
Perm
:
0660
,
Daily
:
true
,
MaxDays
:
7
,
Rotate
:
true
,
Level
:
LevelTrace
,
Perm
:
0660
,
}
return
w
}
...
...
@@ -259,8 +256,8 @@ func (w *fileLogWriter) deleteOldLog() {
}
}()
if
!
info
.
IsDir
()
&&
info
.
ModTime
()
.
Unix
()
<
(
time
.
Now
()
.
Unix
()
-
60
*
60
*
24
*
w
.
MaxDays
)
{
if
strings
.
HasPrefix
(
filepath
.
Base
(
path
),
w
.
fileNameOnly
)
&&
if
!
info
.
IsDir
()
&&
info
.
ModTime
()
.
Add
(
24
*
time
.
Hour
*
time
.
Duration
(
w
.
MaxDays
))
.
Before
(
time
.
Now
()
)
{
if
strings
.
HasPrefix
(
filepath
.
Base
(
path
),
filepath
.
Base
(
w
.
fileNameOnly
)
)
&&
strings
.
HasSuffix
(
filepath
.
Base
(
path
),
w
.
suffix
)
{
os
.
Remove
(
path
)
}
...
...
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