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
1f268526
Commit
1f268526
authored
Oct 28, 2014
by
astaxie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
logs:default support fileline
parent
e11a27f1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
9 additions
and
38 deletions
+9
-38
log.go
log.go
+0
-5
conn.go
logs/conn.go
+1
-1
console.go
logs/console.go
+1
-1
file.go
logs/file.go
+1
-1
log.go
logs/log.go
+6
-30
No files found.
log.go
View file @
1f268526
...
...
@@ -38,11 +38,6 @@ func SetLevel(l int) {
BeeLogger
.
SetLevel
(
l
)
}
func
SetLogFuncCall
(
b
bool
)
{
BeeLogger
.
EnableFuncCallDepth
(
b
)
BeeLogger
.
SetLogFuncCallDepth
(
3
)
}
// logger references the used application logger.
var
BeeLogger
*
logs
.
BeeLogger
...
...
logs/conn.go
View file @
1f268526
...
...
@@ -99,7 +99,7 @@ func (c *ConnWriter) connect() error {
}
c
.
innerWriter
=
conn
c
.
lg
=
log
.
New
(
conn
,
""
,
log
.
Ldate
|
log
.
Ltime
)
c
.
lg
=
log
.
New
(
conn
,
""
,
log
.
Ldate
|
log
.
Ltime
|
log
.
Lshortfile
)
return
nil
}
...
...
logs/console.go
View file @
1f268526
...
...
@@ -51,7 +51,7 @@ type ConsoleWriter struct {
// create ConsoleWriter returning as LoggerInterface.
func
NewConsole
()
LoggerInterface
{
cw
:=
new
(
ConsoleWriter
)
cw
.
lg
=
log
.
New
(
os
.
Stdout
,
""
,
log
.
Ldate
|
log
.
Ltime
)
cw
.
lg
=
log
.
New
(
os
.
Stdout
,
""
,
log
.
Ldate
|
log
.
Ltime
|
log
.
Lshortfile
)
cw
.
Level
=
LevelDebug
return
cw
}
...
...
logs/file.go
View file @
1f268526
...
...
@@ -89,7 +89,7 @@ func NewFileWriter() LoggerInterface {
// use MuxWriter instead direct use os.File for lock write when rotate
w
.
mw
=
new
(
MuxWriter
)
// set MuxWriter as Logger's io.Writer
w
.
Logger
=
log
.
New
(
w
.
mw
,
""
,
log
.
Ldate
|
log
.
Ltime
)
w
.
Logger
=
log
.
New
(
w
.
mw
,
""
,
log
.
Ldate
|
log
.
Ltime
|
log
.
Lshortfile
)
return
w
}
...
...
logs/log.go
View file @
1f268526
...
...
@@ -34,8 +34,7 @@ package logs
import
(
"fmt"
"path"
"runtime"
"sync"
)
...
...
@@ -88,12 +87,10 @@ func Register(name string, log loggerType) {
// BeeLogger is default logger in beego application.
// it can contain several providers and log message into all providers.
type
BeeLogger
struct
{
lock
sync
.
Mutex
level
int
enableFuncCallDepth
bool
loggerFuncCallDepth
int
msg
chan
*
logMsg
outputs
map
[
string
]
LoggerInterface
lock
sync
.
Mutex
level
int
msg
chan
*
logMsg
outputs
map
[
string
]
LoggerInterface
}
type
logMsg
struct
{
...
...
@@ -107,7 +104,6 @@ type logMsg struct {
func
NewLogger
(
channellen
int64
)
*
BeeLogger
{
bl
:=
new
(
BeeLogger
)
bl
.
level
=
LevelDebug
bl
.
loggerFuncCallDepth
=
2
bl
.
msg
=
make
(
chan
*
logMsg
,
channellen
)
bl
.
outputs
=
make
(
map
[
string
]
LoggerInterface
)
//bl.SetLogger("console", "") // default output to console
...
...
@@ -153,17 +149,7 @@ func (bl *BeeLogger) writerMsg(loglevel int, msg string) error {
}
lm
:=
new
(
logMsg
)
lm
.
level
=
loglevel
if
bl
.
enableFuncCallDepth
{
_
,
file
,
line
,
ok
:=
runtime
.
Caller
(
bl
.
loggerFuncCallDepth
)
if
ok
{
_
,
filename
:=
path
.
Split
(
file
)
lm
.
msg
=
fmt
.
Sprintf
(
"[%s:%d] %s"
,
filename
,
line
,
msg
)
}
else
{
lm
.
msg
=
msg
}
}
else
{
lm
.
msg
=
msg
}
lm
.
msg
=
msg
bl
.
msg
<-
lm
return
nil
}
...
...
@@ -176,16 +162,6 @@ func (bl *BeeLogger) SetLevel(l int) {
bl
.
level
=
l
}
// set log funcCallDepth
func
(
bl
*
BeeLogger
)
SetLogFuncCallDepth
(
d
int
)
{
bl
.
loggerFuncCallDepth
=
d
}
// enable log funcCallDepth
func
(
bl
*
BeeLogger
)
EnableFuncCallDepth
(
b
bool
)
{
bl
.
enableFuncCallDepth
=
b
}
// start logger chan reading.
// when chan is not empty, write logs.
func
(
bl
*
BeeLogger
)
startLogger
()
{
...
...
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