-
Notifications
You must be signed in to change notification settings - Fork 212
Expand file tree
/
Copy pathlogger.go
More file actions
32 lines (29 loc) · 859 Bytes
/
Copy pathlogger.go
File metadata and controls
32 lines (29 loc) · 859 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/**
* @Author 风起
* @contact: onlyzaliks@gmail.com
* @File: logger.go
* @Time: 2022/5/5 9:09
**/
package lib
import "github.com/phachon/go-logger"
func Logger() *go_logger.Logger {
logger := go_logger.NewLogger()
if err := logger.Detach("console"); err != nil {
return nil
}
console := &go_logger.ConsoleConfig{
Color: true, // Whether the text shows color
Format: "[%timestamp_format%] %body%",
}
fileConfig := &go_logger.FileConfig{
Filename: "./RedGuard.log",
MaxSize: 1024 * 1024, // Maximum file size (KB). The default value is 0
MaxLine: 50000,
MaxBak: 1,
DateSlice: "d",
Format: "[%timestamp_format%] [%function%] %body%",
}
logger.Attach("file", go_logger.LOGGER_LEVEL_DEBUG, fileConfig)
logger.Attach("console", go_logger.LOGGER_LEVEL_DEBUG, console)
return logger
}