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
5a2eea07
Commit
5a2eea07
authored
Jun 01, 2017
by
Jia Li Ong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Provide permission to access old log files to everyone
parent
cab8458c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
7 deletions
+16
-7
file.go
logs/file.go
+16
-7
No files found.
logs/file.go
View file @
5a2eea07
...
...
@@ -56,17 +56,20 @@ type fileLogWriter struct {
Perm
string
`json:"perm"`
OtherPerm
string
`json:"otherperm"`
fileNameOnly
,
suffix
string
// like "project.log", project is fileNameOnly and .log is suffix
}
// newFileWriter create a FileLogWriter returning as LoggerInterface.
func
newFileWriter
()
Logger
{
w
:=
&
fileLogWriter
{
Daily
:
true
,
MaxDays
:
7
,
Rotate
:
true
,
Level
:
LevelTrace
,
Perm
:
"0660"
,
Daily
:
true
,
MaxDays
:
7
,
Rotate
:
true
,
OtherPerm
:
"0440"
,
Level
:
LevelTrace
,
Perm
:
"0660"
,
}
return
w
}
...
...
@@ -237,8 +240,12 @@ func (w *fileLogWriter) doRotate(logTime time.Time) error {
// Find the next available number
num
:=
1
fName
:=
""
otherPerm
,
err
:=
strconv
.
ParseInt
(
w
.
OtherPerm
,
8
,
64
)
if
err
!=
nil
{
return
err
}
_
,
err
:
=
os
.
Lstat
(
w
.
Filename
)
_
,
err
=
os
.
Lstat
(
w
.
Filename
)
if
err
!=
nil
{
//even if the file is not exist or other ,we should RESTART the logger
goto
RESTART_LOGGER
...
...
@@ -271,7 +278,9 @@ func (w *fileLogWriter) doRotate(logTime time.Time) error {
if
err
!=
nil
{
goto
RESTART_LOGGER
}
err
=
os
.
Chmod
(
fName
,
os
.
FileMode
(
0440
))
//err = os.Chmod(fName, os.FileMode(0444))
err
=
os
.
Chmod
(
fName
,
os
.
FileMode
(
otherPerm
))
// re-start logger
RESTART_LOGGER
:
...
...
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