Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
caddy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
caddy
Commits
bb5a322c
Commit
bb5a322c
authored
Aug 08, 2015
by
Maxime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added lumberjack library for log rolling
parent
afd6b7ea
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
2 deletions
+14
-2
config/setup/errors.go
config/setup/errors.go
+7
-1
config/setup/log.go
config/setup/log.go
+7
-1
No files found.
config/setup/errors.go
View file @
bb5a322c
...
@@ -11,6 +11,7 @@ import (
...
@@ -11,6 +11,7 @@ import (
"github.com/hashicorp/go-syslog"
"github.com/hashicorp/go-syslog"
"github.com/mholt/caddy/middleware"
"github.com/mholt/caddy/middleware"
"github.com/mholt/caddy/middleware/errors"
"github.com/mholt/caddy/middleware/errors"
"gopkg.in/natefinch/lumberjack.v2"
)
)
// Errors configures a new gzip middleware instance.
// Errors configures a new gzip middleware instance.
...
@@ -35,10 +36,15 @@ func Errors(c *Controller) (middleware.Middleware, error) {
...
@@ -35,10 +36,15 @@ func Errors(c *Controller) (middleware.Middleware, error) {
return
err
return
err
}
}
}
else
if
handler
.
LogFile
!=
""
{
}
else
if
handler
.
LogFile
!=
""
{
file
,
err
=
os
.
OpenFile
(
handler
.
LogFile
,
os
.
O_RDWR
|
os
.
O_CREATE
|
os
.
O_APPEND
,
0644
)
_
,
err
=
os
.
OpenFile
(
handler
.
LogFile
,
os
.
O_RDWR
|
os
.
O_CREATE
|
os
.
O_APPEND
,
0644
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
file
=
&
lumberjack
.
Logger
{
Filename
:
handler
.
LogFile
,
MaxSize
:
20
,
MaxBackups
:
10
,
}
}
}
handler
.
Log
=
log
.
New
(
file
,
""
,
0
)
handler
.
Log
=
log
.
New
(
file
,
""
,
0
)
...
...
config/setup/log.go
View file @
bb5a322c
...
@@ -9,6 +9,7 @@ import (
...
@@ -9,6 +9,7 @@ import (
"github.com/mholt/caddy/middleware"
"github.com/mholt/caddy/middleware"
caddylog
"github.com/mholt/caddy/middleware/log"
caddylog
"github.com/mholt/caddy/middleware/log"
"github.com/mholt/caddy/server"
"github.com/mholt/caddy/server"
"gopkg.in/natefinch/lumberjack.v2"
)
)
// Log sets up the logging middleware.
// Log sets up the logging middleware.
...
@@ -34,10 +35,15 @@ func Log(c *Controller) (middleware.Middleware, error) {
...
@@ -34,10 +35,15 @@ func Log(c *Controller) (middleware.Middleware, error) {
return
err
return
err
}
}
}
else
{
}
else
{
file
,
err
=
os
.
OpenFile
(
rules
[
i
]
.
OutputFile
,
os
.
O_RDWR
|
os
.
O_CREATE
|
os
.
O_APPEND
,
0644
)
_
,
err
=
os
.
OpenFile
(
rules
[
i
]
.
OutputFile
,
os
.
O_RDWR
|
os
.
O_CREATE
|
os
.
O_APPEND
,
0644
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
file
=
&
lumberjack
.
Logger
{
Filename
:
rules
[
i
]
.
OutputFile
,
MaxSize
:
20
,
MaxBackups
:
10
,
}
}
}
rules
[
i
]
.
Log
=
log
.
New
(
file
,
""
,
0
)
rules
[
i
]
.
Log
=
log
.
New
(
file
,
""
,
0
)
...
...
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