Skip to content

πŸ”– Logger ​

go
import (
	"github.com/thuongtruong109/gouse"
)

1. Write log default ​

Description: Write log to file (as default)
Input params: (logId, logMessage, output string)

go
func WriteLogDefault() {
	gouse.WriteLogDefault("id_1", "log message", "output.log")
}

2. Write log as gouse ​

Description: Write log to file (as Gouse style format)
Input params: (prefix, msg, filePath string, err ...interface{})

go
func WriteLogAsGouse() {
	gouse.WriteLog("[POST]", "message", "output.log", "error")
}

3. Write log with type ​

Description: Write log by types to file (as Gouse style format)
Input params: (msg string, err interface{})

go
func WriteLogWithType() {
	gouse.WriteErrorLog("log message", "error")
	gouse.WriteInfoLog("log message")
	gouse.WriteAccessLog("log message")
}

4. Auto rotate truncate log ​

Description: Truncate log file
Input params: (output string, maxFileSize ...int64)

go
func AutoRotateTruncateLog() {
	gouse.RotateLog("output.log", 1024)
}

Released under the MIT License.