Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
二次元的罪恶王冠
beego
提交
77c11091
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,发现更多精彩内容 >>
提交
77c11091
编写于
2月 23, 2015
作者:
F
fuxiaohei
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
code simplify for package logs
上级
29d48238
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
18 addition
and
31 deletion
+18
-31
logs/conn.go
logs/conn.go
+3
-8
logs/console.go
logs/console.go
+8
-10
logs/file.go
logs/file.go
+2
-7
logs/log.go
logs/log.go
+2
-2
logs/smtp.go
logs/smtp.go
+3
-4
未找到文件。
logs/conn.go
浏览文件 @
77c11091
...
...
@@ -43,11 +43,7 @@ func NewConn() LoggerInterface {
// init connection writer with json config.
// json config only need key "level".
func
(
c
*
ConnWriter
)
Init
(
jsonconfig
string
)
error
{
err
:=
json
.
Unmarshal
([]
byte
(
jsonconfig
),
c
)
if
err
!=
nil
{
return
err
}
return
nil
return
json
.
Unmarshal
([]
byte
(
jsonconfig
),
c
)
}
// write message in connection.
...
...
@@ -77,10 +73,9 @@ func (c *ConnWriter) Flush() {
// destroy connection writer and close tcp listener.
func
(
c
*
ConnWriter
)
Destroy
()
{
if
c
.
innerWriter
==
nil
{
return
}
if
c
.
innerWriter
!=
nil
{
c
.
innerWriter
.
Close
()
}
}
func
(
c
*
ConnWriter
)
connect
()
error
{
...
...
logs/console.go
浏览文件 @
77c11091
...
...
@@ -50,9 +50,10 @@ 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
.
Level
=
LevelDebug
cw
:=
&
ConsoleWriter
{
lg
:
log
.
New
(
os
.
Stdout
,
""
,
log
.
Ldate
|
log
.
Ltime
),
Level
:
LevelDebug
,
}
return
cw
}
...
...
@@ -62,11 +63,7 @@ func (c *ConsoleWriter) Init(jsonconfig string) error {
if
len
(
jsonconfig
)
==
0
{
return
nil
}
err
:=
json
.
Unmarshal
([]
byte
(
jsonconfig
),
c
)
if
err
!=
nil
{
return
err
}
return
nil
return
json
.
Unmarshal
([]
byte
(
jsonconfig
),
c
)
}
// write message in console.
...
...
@@ -76,9 +73,10 @@ func (c *ConsoleWriter) WriteMsg(msg string, level int) error {
}
if
goos
:=
runtime
.
GOOS
;
goos
==
"windows"
{
c
.
lg
.
Println
(
msg
)
}
else
{
c
.
lg
.
Println
(
colors
[
level
](
msg
))
return
nil
}
c
.
lg
.
Println
(
colors
[
level
](
msg
))
return
nil
}
...
...
logs/file.go
浏览文件 @
77c11091
...
...
@@ -123,11 +123,7 @@ func (w *FileLogWriter) startLogger() error {
return
err
}
w
.
mw
.
SetFd
(
fd
)
err
=
w
.
initFd
()
if
err
!=
nil
{
return
err
}
return
nil
return
w
.
initFd
()
}
func
(
w
*
FileLogWriter
)
docheck
(
size
int
)
{
...
...
@@ -170,14 +166,13 @@ func (w *FileLogWriter) initFd() error {
}
w
.
maxsize_cursize
=
int
(
finfo
.
Size
())
w
.
daily_opendate
=
time
.
Now
()
.
Day
()
w
.
maxlines_curlines
=
0
if
finfo
.
Size
()
>
0
{
count
,
err
:=
w
.
lines
()
if
err
!=
nil
{
return
err
}
w
.
maxlines_curlines
=
count
}
else
{
w
.
maxlines_curlines
=
0
}
return
nil
}
...
...
logs/log.go
浏览文件 @
77c11091
...
...
@@ -292,9 +292,9 @@ func (bl *BeeLogger) Close() {
fmt
.
Println
(
"ERROR, unable to WriteMsg (while closing logger):"
,
err
)
}
}
}
else
{
break
continue
}
break
}
for
_
,
l
:=
range
bl
.
outputs
{
l
.
Flush
()
...
...
logs/smtp.go
浏览文件 @
77c11091
...
...
@@ -25,7 +25,8 @@ import (
)
const
(
subjectPhrase
=
"Diagnostic message from server"
// no usage
// subjectPhrase = "Diagnostic message from server"
)
// smtpWriter implements LoggerInterface and is used to send emails via given SMTP-server.
...
...
@@ -146,9 +147,7 @@ func (s *SmtpWriter) WriteMsg(msg string, level int) error {
mailmsg
:=
[]
byte
(
"To: "
+
strings
.
Join
(
s
.
RecipientAddresses
,
";"
)
+
"
\r\n
From: "
+
s
.
FromAddress
+
"<"
+
s
.
FromAddress
+
">
\r\n
Subject: "
+
s
.
Subject
+
"
\r\n
"
+
content_type
+
"
\r\n\r\n
"
+
fmt
.
Sprintf
(
".%s"
,
time
.
Now
()
.
Format
(
"2006-01-02 15:04:05"
))
+
msg
)
err
:=
s
.
sendMail
(
s
.
Host
,
auth
,
s
.
FromAddress
,
s
.
RecipientAddresses
,
mailmsg
)
return
err
return
s
.
sendMail
(
s
.
Host
,
auth
,
s
.
FromAddress
,
s
.
RecipientAddresses
,
mailmsg
)
}
// implementing method. empty.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录