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
2c123832
Commit
2c123832
authored
May 17, 2016
by
nullne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove attribute perm to make it more brief
parent
d679a4b8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
9 deletions
+6
-9
file.go
logs/file.go
+6
-9
No files found.
logs/file.go
View file @
2c123832
...
...
@@ -55,7 +55,6 @@ type fileLogWriter struct {
Level
int
`json:"level"`
Perm
string
`json:"perm"`
perm
os
.
FileMode
fileNameOnly
,
suffix
string
// like "project.log", project is fileNameOnly and .log is suffix
}
...
...
@@ -68,7 +67,6 @@ func newFileWriter() Logger {
Rotate
:
true
,
Level
:
LevelTrace
,
Perm
:
"0660"
,
perm
:
0660
,
}
return
w
}
...
...
@@ -82,7 +80,7 @@ func newFileWriter() Logger {
// "daily":true,
// "maxDays":15,
// "rotate":true,
// "perm":
0600
// "perm":
"0600"
// }
func
(
w
*
fileLogWriter
)
Init
(
jsonConfig
string
)
error
{
err
:=
json
.
Unmarshal
([]
byte
(
jsonConfig
),
w
)
...
...
@@ -92,11 +90,6 @@ func (w *fileLogWriter) Init(jsonConfig string) error {
if
len
(
w
.
Filename
)
==
0
{
return
errors
.
New
(
"jsonconfig must have filename"
)
}
perm
,
err
:=
strconv
.
ParseInt
(
w
.
Perm
,
8
,
64
)
if
err
!=
nil
{
return
err
}
w
.
perm
=
os
.
FileMode
(
perm
)
w
.
suffix
=
filepath
.
Ext
(
w
.
Filename
)
w
.
fileNameOnly
=
strings
.
TrimSuffix
(
w
.
Filename
,
w
.
suffix
)
if
w
.
suffix
==
""
{
...
...
@@ -161,7 +154,11 @@ func (w *fileLogWriter) WriteMsg(when time.Time, msg string, level int) error {
func
(
w
*
fileLogWriter
)
createLogFile
()
(
*
os
.
File
,
error
)
{
// Open the log file
fd
,
err
:=
os
.
OpenFile
(
w
.
Filename
,
os
.
O_WRONLY
|
os
.
O_APPEND
|
os
.
O_CREATE
,
w
.
perm
)
perm
,
err
:=
strconv
.
ParseInt
(
w
.
Perm
,
8
,
64
)
if
err
!=
nil
{
return
nil
,
err
}
fd
,
err
:=
os
.
OpenFile
(
w
.
Filename
,
os
.
O_WRONLY
|
os
.
O_APPEND
|
os
.
O_CREATE
,
os
.
FileMode
(
perm
))
return
fd
,
err
}
...
...
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