Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
张磊
/
FileStorageBeego
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
ba5e393e
authored
2013-11-27 17:50:10 +0800
by
astaxie
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
add flush & read all chan data
1 parent
690d77e9
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
34 additions
and
0 deletions
logs/conn.go
logs/console.go
logs/file.go
logs/log.go
logs/smtp.go
logs/conn.go
View file @
ba5e393
...
...
@@ -65,6 +65,10 @@ func (c *ConnWriter) WriteMsg(msg string, level int) error {
return
nil
}
func
(
c
*
ConnWriter
)
Flush
()
{
}
func
(
c
*
ConnWriter
)
Destroy
()
{
if
c
.
innerWriter
==
nil
{
return
...
...
logs/console.go
View file @
ba5e393
...
...
@@ -42,6 +42,10 @@ func (c *ConsoleWriter) Destroy() {
}
func
(
c
*
ConsoleWriter
)
Flush
()
{
}
func
init
()
{
Register
(
"console"
,
NewConsole
)
}
...
...
logs/file.go
View file @
ba5e393
...
...
@@ -237,6 +237,10 @@ func (w *FileLogWriter) Destroy() {
w
.
mw
.
fd
.
Close
()
}
func
(
w
*
FileLogWriter
)
Flush
()
{
w
.
mw
.
fd
.
Sync
()
}
func
init
()
{
Register
(
"file"
,
NewFileWriter
)
}
...
...
logs/log.go
View file @
ba5e393
...
...
@@ -20,6 +20,7 @@ type LoggerInterface interface {
Init
(
config
string
)
error
WriteMsg
(
msg
string
,
level
int
)
error
Destroy
()
Flush
()
}
var
adapters
=
make
(
map
[
string
]
loggerType
)
...
...
@@ -140,8 +141,26 @@ func (bl *BeeLogger) Critical(format string, v ...interface{}) {
bl
.
writerMsg
(
LevelCritical
,
msg
)
}
//flush all chan data
func
(
bl
*
BeeLogger
)
Flush
()
{
for
_
,
l
:=
range
bl
.
outputs
{
l
.
Flush
()
}
}
func
(
bl
*
BeeLogger
)
Close
()
{
for
{
if
len
(
bl
.
msg
)
>
0
{
bm
:=
<-
bl
.
msg
for
_
,
l
:=
range
bl
.
outputs
{
l
.
WriteMsg
(
bm
.
msg
,
bm
.
level
)
}
}
else
{
break
}
}
for
_
,
l
:=
range
bl
.
outputs
{
l
.
Flush
()
l
.
Destroy
()
}
}
...
...
logs/smtp.go
View file @
ba5e393
...
...
@@ -92,6 +92,9 @@ func (s *SmtpWriter) WriteMsg(msg string, level int) error {
return
err
}
func
(
s
*
SmtpWriter
)
Flush
()
{
return
}
func
(
s
*
SmtpWriter
)
Destroy
()
{
return
}
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
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 post a comment