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
9572fdcf
Commit
9572fdcf
authored
Jun 22, 2016
by
GuyCheung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update error on type of w.Perm; change unit test perm value
parent
cb3f240f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
3 deletions
+4
-3
file.go
logs/file.go
+1
-1
file_test.go
logs/file_test.go
+3
-2
No files found.
logs/file.go
View file @
9572fdcf
...
...
@@ -161,7 +161,7 @@ func (w *fileLogWriter) createLogFile() (*os.File, error) {
fd
,
err
:=
os
.
OpenFile
(
w
.
Filename
,
os
.
O_WRONLY
|
os
.
O_APPEND
|
os
.
O_CREATE
,
os
.
FileMode
(
perm
))
if
err
==
nil
{
// Make sure file perm is user set perm cause of `os.OpenFile` will obey umask
os
.
Chmod
(
w
.
Filename
,
w
.
Perm
)
os
.
Chmod
(
w
.
Filename
,
os
.
FileMode
(
perm
)
)
}
return
fd
,
err
}
...
...
logs/file_test.go
View file @
9572fdcf
...
...
@@ -26,7 +26,8 @@ import (
func
TestFilePerm
(
t
*
testing
.
T
)
{
log
:=
NewLogger
(
10000
)
log
.
SetLogger
(
"file"
,
`{"filename":"test.log", "perm": "0600"}`
)
// use 0666 as test perm cause the default umask is 022
log
.
SetLogger
(
"file"
,
`{"filename":"test.log", "perm": "0666"}`
)
log
.
Debug
(
"debug"
)
log
.
Informational
(
"info"
)
log
.
Notice
(
"notice"
)
...
...
@@ -39,7 +40,7 @@ func TestFilePerm(t *testing.T) {
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
file
.
Mode
()
!=
06
00
{
if
file
.
Mode
()
!=
06
66
{
t
.
Fatal
(
"unexpected log file permission"
)
}
os
.
Remove
(
"test.log"
)
...
...
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