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
c8bbfb75
Commit
c8bbfb75
authored
Mar 14, 2016
by
astaxie
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1782 from JessonChan/some_wip
BeeLogger can be the writer of http server's log
parents
e4066d82
c92c3fc8
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
2 deletions
+21
-2
app.go
app.go
+2
-0
log.go
logs/log.go
+17
-1
router.go
router.go
+2
-1
No files found.
app.go
View file @
c8bbfb75
...
...
@@ -16,6 +16,7 @@ package beego
import
(
"fmt"
"log"
"net"
"net/http"
"net/http/fcgi"
...
...
@@ -95,6 +96,7 @@ func (app *App) Run() {
app
.
Server
.
Handler
=
app
.
Handlers
app
.
Server
.
ReadTimeout
=
time
.
Duration
(
BConfig
.
Listen
.
ServerTimeOut
)
*
time
.
Second
app
.
Server
.
WriteTimeout
=
time
.
Duration
(
BConfig
.
Listen
.
ServerTimeOut
)
*
time
.
Second
app
.
Server
.
ErrorLog
=
log
.
New
(
BeeLogger
,
""
,
0
)
// run graceful mode
if
BConfig
.
Listen
.
Graceful
{
...
...
logs/log.go
View file @
c8bbfb75
...
...
@@ -196,6 +196,22 @@ func (bl *BeeLogger) writeToLoggers(when time.Time, msg string, level int) {
}
}
func
(
bl
*
BeeLogger
)
Write
(
p
[]
byte
)
(
n
int
,
err
error
)
{
if
len
(
p
)
==
0
{
return
0
,
nil
}
// writeMsg will always add a '\n' character
if
p
[
len
(
p
)
-
1
]
==
'\n'
{
p
=
p
[
0
:
len
(
p
)
-
1
]
}
// set LevelCritical to ensure all log message will be write out
err
=
bl
.
writeMsg
(
LevelCritical
,
string
(
p
))
if
err
==
nil
{
return
len
(
p
),
err
}
return
0
,
err
}
func
(
bl
*
BeeLogger
)
writeMsg
(
logLevel
int
,
msg
string
)
error
{
when
:=
time
.
Now
()
if
bl
.
enableFuncCallDepth
{
...
...
@@ -205,7 +221,7 @@ func (bl *BeeLogger) writeMsg(logLevel int, msg string) error {
line
=
0
}
_
,
filename
:=
path
.
Split
(
file
)
msg
=
"["
+
filename
+
":"
+
strconv
.
FormatInt
(
int64
(
line
),
10
)
+
"]"
+
msg
msg
=
"["
+
filename
+
":"
+
strconv
.
FormatInt
(
int64
(
line
),
10
)
+
"]
"
+
msg
}
if
bl
.
asynchronous
{
lm
:=
logMsgPool
.
Get
()
.
(
*
logMsg
)
...
...
router.go
View file @
c8bbfb75
...
...
@@ -802,9 +802,9 @@ func (p *ControllerRegister) ServeHTTP(rw http.ResponseWriter, r *http.Request)
p
.
execFilter
(
context
,
FinishRouter
,
urlPath
)
Admin
:
timeDur
:=
time
.
Since
(
startTime
)
//admin module record QPS
if
BConfig
.
Listen
.
EnableAdmin
{
timeDur
:=
time
.
Since
(
startTime
)
if
FilterMonitorFunc
(
r
.
Method
,
r
.
URL
.
Path
,
timeDur
)
{
if
runRouter
!=
nil
{
go
toolbox
.
StatisticsMap
.
AddStatistics
(
r
.
Method
,
r
.
URL
.
Path
,
runRouter
.
Name
(),
timeDur
)
...
...
@@ -815,6 +815,7 @@ Admin:
}
if
BConfig
.
RunMode
==
DEV
||
BConfig
.
Log
.
AccessLogs
{
timeDur
:=
time
.
Since
(
startTime
)
var
devInfo
string
if
findRouter
{
if
routerInfo
!=
nil
{
...
...
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