Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
二次元的罪恶王冠
beego
提交
68c3bdfd
B
beego
项目概览
二次元的罪恶王冠
/
beego
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
B
beego
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
68c3bdfd
编写于
10月 30, 2014
作者:
A
astaxie
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Revert "logs:default support fileline"
This reverts commit
1f268526
.
上级
ecd0a548
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
38 addition
and
9 deletion
+38
-9
log.go
log.go
+5
-0
logs/conn.go
logs/conn.go
+1
-1
logs/console.go
logs/console.go
+1
-1
logs/file.go
logs/file.go
+1
-1
logs/log.go
logs/log.go
+30
-6
未找到文件。
log.go
浏览文件 @
68c3bdfd
...
...
@@ -38,6 +38,11 @@ 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
浏览文件 @
68c3bdfd
...
...
@@ -99,7 +99,7 @@ func (c *ConnWriter) connect() error {
}
c
.
innerWriter
=
conn
c
.
lg
=
log
.
New
(
conn
,
""
,
log
.
Ldate
|
log
.
Ltime
|
log
.
Lshortfile
)
c
.
lg
=
log
.
New
(
conn
,
""
,
log
.
Ldate
|
log
.
Ltime
)
return
nil
}
...
...
logs/console.go
浏览文件 @
68c3bdfd
...
...
@@ -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
|
log
.
Lshortfile
)
cw
.
lg
=
log
.
New
(
os
.
Stdout
,
""
,
log
.
Ldate
|
log
.
Ltime
)
cw
.
Level
=
LevelDebug
return
cw
}
...
...
logs/file.go
浏览文件 @
68c3bdfd
...
...
@@ -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
|
log
.
Lshortfile
)
w
.
Logger
=
log
.
New
(
w
.
mw
,
""
,
log
.
Ldate
|
log
.
Ltime
)
return
w
}
...
...
logs/log.go
浏览文件 @
68c3bdfd
...
...
@@ -34,7 +34,8 @@ package logs
import
(
"fmt"
"path"
"runtime"
"sync"
)
...
...
@@ -87,10 +88,12 @@ 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
msg
chan
*
logMsg
outputs
map
[
string
]
LoggerInterface
lock
sync
.
Mutex
level
int
enableFuncCallDepth
bool
loggerFuncCallDepth
int
msg
chan
*
logMsg
outputs
map
[
string
]
LoggerInterface
}
type
logMsg
struct
{
...
...
@@ -104,6 +107,7 @@ 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
...
...
@@ -149,7 +153,17 @@ func (bl *BeeLogger) writerMsg(loglevel int, msg string) error {
}
lm
:=
new
(
logMsg
)
lm
.
level
=
loglevel
lm
.
msg
=
msg
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
}
bl
.
msg
<-
lm
return
nil
}
...
...
@@ -162,6 +176,16 @@ 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
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录