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
778a5a11
Commit
778a5a11
authored
Mar 11, 2016
by
astaxie
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1781 from JessonChan/develop
duplicate adapter logger bug fixed
parents
420cd507
48010996
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
8 deletions
+16
-8
log.go
logs/log.go
+16
-8
No files found.
logs/log.go
View file @
778a5a11
...
...
@@ -146,17 +146,25 @@ func (bl *BeeLogger) Async() *BeeLogger {
func
(
bl
*
BeeLogger
)
SetLogger
(
adapterName
string
,
config
string
)
error
{
bl
.
lock
.
Lock
()
defer
bl
.
lock
.
Unlock
()
if
log
,
ok
:=
adapters
[
adapterName
];
ok
{
lg
:=
log
()
err
:=
lg
.
Init
(
config
)
if
err
!=
nil
{
fmt
.
Fprintln
(
os
.
Stderr
,
"logs.BeeLogger.SetLogger: "
+
err
.
Error
())
return
err
for
_
,
l
:=
range
bl
.
outputs
{
if
l
.
name
==
adapterName
{
return
fmt
.
Errorf
(
"logs: duplicate adaptername %q (you have set this logger before)"
,
adapterName
)
}
bl
.
outputs
=
append
(
bl
.
outputs
,
&
nameLogger
{
name
:
adapterName
,
Logger
:
lg
})
}
else
{
}
log
,
ok
:=
adapters
[
adapterName
]
if
!
ok
{
return
fmt
.
Errorf
(
"logs: unknown adaptername %q (forgotten Register?)"
,
adapterName
)
}
lg
:=
log
()
err
:=
lg
.
Init
(
config
)
if
err
!=
nil
{
fmt
.
Fprintln
(
os
.
Stderr
,
"logs.BeeLogger.SetLogger: "
+
err
.
Error
())
return
err
}
bl
.
outputs
=
append
(
bl
.
outputs
,
&
nameLogger
{
name
:
adapterName
,
Logger
:
lg
})
return
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