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
93201977
Commit
93201977
authored
Apr 10, 2017
by
zjjott
Committed by
朱涧江
Apr 10, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: log mode 0440 should not be 440
parent
323a1c42
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
2 deletions
+22
-2
file.go
logs/file.go
+1
-1
file_test.go
logs/file_test.go
+21
-1
No files found.
logs/file.go
View file @
93201977
...
...
@@ -270,7 +270,7 @@ func (w *fileLogWriter) doRotate(logTime time.Time) error {
// Rename the file to its new found name
// even if occurs error,we MUST guarantee to restart new logger
err
=
os
.
Rename
(
w
.
Filename
,
fName
)
err
=
os
.
Chmod
(
fName
,
os
.
FileMode
(
440
))
err
=
os
.
Chmod
(
fName
,
os
.
FileMode
(
0
440
))
// re-start logger
RESTART_LOGGER
:
...
...
logs/file_test.go
View file @
93201977
...
...
@@ -162,7 +162,27 @@ func TestFileRotate_05(t *testing.T) {
testFileDailyRotate
(
t
,
fn1
,
fn2
)
os
.
Remove
(
fn
)
}
func
TestFileRotate_06
(
t
*
testing
.
T
)
{
//test file mode
log
:=
NewLogger
(
10000
)
log
.
SetLogger
(
"file"
,
`{"filename":"test3.log","maxlines":4}`
)
log
.
Debug
(
"debug"
)
log
.
Info
(
"info"
)
log
.
Notice
(
"notice"
)
log
.
Warning
(
"warning"
)
log
.
Error
(
"error"
)
log
.
Alert
(
"alert"
)
log
.
Critical
(
"critical"
)
log
.
Emergency
(
"emergency"
)
rotateName
:=
"test3"
+
fmt
.
Sprintf
(
".%s.%03d"
,
time
.
Now
()
.
Format
(
"2006-01-02"
),
1
)
+
".log"
s
,
_
:=
os
.
Lstat
(
rotateName
)
if
s
.
Mode
()
!=
0440
{
os
.
Remove
(
rotateName
)
os
.
Remove
(
"test3.log"
)
t
.
Fatal
(
"rotate file mode error"
)
}
os
.
Remove
(
rotateName
)
os
.
Remove
(
"test3.log"
)
}
func
testFileRotate
(
t
*
testing
.
T
,
fn1
,
fn2
string
)
{
fw
:=
&
fileLogWriter
{
Daily
:
true
,
...
...
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