loggo/format.go

82 lines
1.9 KiB
Go
Raw Permalink Normal View History

2023-11-02 11:24:33 +01:00
package loggo
// timestamp placeholder
const PLACEHOLDER_TIMESTAMP = "$TIMESTAMP$"
// log level placeholder
const PLACEHOLDER_LOGLEVEL = "$LOGLEVEL$"
// message placeholder
const PLACEHOLDER_MESSAGE = "$MESSAGE$"
// time difference placeholder
const PLACEHOLDER_TIMEDIFF = "$TIMEDIFF$"
// extras placeholder
const PLACEHOLDER_EXTRAS = "$EXTRAS$"
// current log format (defaults to: "$TIMESTAMP$ - [$LOGLEVEL$] > $MESSAGE ($EXTRAS$) [$TIMEDIFF$]")
2023-11-02 14:21:51 +01:00
var logFormat = PLACEHOLDER_TIMESTAMP + " - [" + PLACEHOLDER_LOGLEVEL + "] > " + PLACEHOLDER_MESSAGE + " (" + PLACEHOLDER_EXTRAS + ") [" + PLACEHOLDER_TIMEDIFF + "]"
2023-11-02 11:24:33 +01:00
// current date format (defaults to: "02.01.2006 15:04:05")
var dateFormat = "02.01.2006 15:04:05"
2023-11-02 12:07:38 +01:00
// current time diff format (defaults to: "[$TIMEDIFF$]")
var timediffFormat = "[" + PLACEHOLDER_TIMEDIFF + "]"
// current extras format (defaults to: "($EXTRAS$)")
var extrasFormat = "(" + PLACEHOLDER_EXTRAS + ")"
2023-11-02 11:24:33 +01:00
// current extras separator (defaults to: "|")
var extrasSeparator = " | "
2023-11-02 11:24:33 +01:00
// get current log format
func GetLogFormat() string {
return logFormat
}
// set current prefix format
func SetLogFormat(format string) {
logFormat = format
}
// get current date format
func GetDateFormat() string {
return dateFormat
}
// set current date format
func SetDateFormat(format string) {
dateFormat = format
}
// get current extras separator
func GetExtrasSeparator() string {
return extrasSeparator
}
// set current extras separator
func SetExtrasSeparator(separator string) {
extrasSeparator = separator
}
2023-11-02 12:07:38 +01:00
// get current extras format
func GetExtrasFormat() string {
return extrasFormat
}
// set current extras format
func SetExtrasFormat(format string) {
extrasFormat = format
}
// get current time diff format
func GetTimediffFormat() string {
return timediffFormat
}
// set current time diff format
func SetTimediffFormat(format string) {
timediffFormat = format
}