mirror of
https://github.com/beego/bee.git
synced 2024-11-22 05:00:54 +00:00
Acquire lock when logging
This commit is contained in:
parent
deacdaa667
commit
21fc177551
@ -558,8 +558,7 @@ func createapi(cmd *Command, args []string) int {
|
||||
|
||||
apppath, packpath, err := checkEnv(args[0])
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
os.Exit(2)
|
||||
logger.Fatalf("%s", err)
|
||||
}
|
||||
if driver == "" {
|
||||
driver = "mysql"
|
||||
|
@ -61,7 +61,6 @@ type LogRecord struct {
|
||||
var (
|
||||
logRecordTemplate *template.Template
|
||||
debugLogRecordTemplate *template.Template
|
||||
debugLogFormat string
|
||||
)
|
||||
|
||||
func init() {
|
||||
@ -141,6 +140,10 @@ func (l *BeeLogger) getColorLevel(level int) string {
|
||||
// mustLog logs the message according to the specified level and arguments.
|
||||
// It panics in case of an error.
|
||||
func (l *BeeLogger) mustLog(level int, message string, args ...interface{}) {
|
||||
// Acquire the lock
|
||||
l.mu.Lock()
|
||||
defer l.mu.Unlock()
|
||||
|
||||
// Create the logging record and pass into the output
|
||||
record := LogRecord{
|
||||
ID: fmt.Sprintf("%04d", atomic.AddUint64(&sequenceNo, 1)),
|
||||
|
Loading…
Reference in New Issue
Block a user