-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #298 from cnlh/dev
Dev
- Loading branch information
Showing
15 changed files
with
350 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package common | ||
|
||
import ( | ||
"github.com/astaxie/beego/logs" | ||
"time" | ||
) | ||
|
||
const MaxMsgLen = 5000 | ||
|
||
var logMsgs string | ||
|
||
func init() { | ||
logs.Register("store", func() logs.Logger { | ||
return new(StoreMsg) | ||
}) | ||
} | ||
|
||
func GetLogMsg() string { | ||
return logMsgs | ||
} | ||
|
||
type StoreMsg struct { | ||
} | ||
|
||
func (lg *StoreMsg) Init(config string) error { | ||
return nil | ||
} | ||
|
||
func (lg *StoreMsg) WriteMsg(when time.Time, msg string, level int) error { | ||
m := when.Format("2006-01-02 15:04:05") + " " + msg + "\r\n" | ||
if len(logMsgs) > MaxMsgLen { | ||
start := MaxMsgLen - len(m) | ||
if start <= 0 { | ||
start = MaxMsgLen | ||
} | ||
logMsgs = logMsgs[start:] | ||
} | ||
logMsgs += m | ||
return nil | ||
} | ||
|
||
func (lg *StoreMsg) Destroy() { | ||
return | ||
} | ||
|
||
func (lg *StoreMsg) Flush() { | ||
return | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.