81 lines
1.9 KiB
Go
81 lines
1.9 KiB
Go
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$]")
|
|
var logFormat = PLACEHOLDER_TIMESTAMP + " - [" + PLACEHOLDER_LOGLEVEL + "] > " + PLACEHOLDER_MESSAGE + " (" + PLACEHOLDER_EXTRAS + ") [" + PLACEHOLDER_TIMEDIFF + "]"
|
|
|
|
// current date format (defaults to: "02.01.2006 15:04:05")
|
|
var dateFormat = "02.01.2006 15:04:05"
|
|
|
|
// current time diff format (defaults to: "[$TIMEDIFF$]")
|
|
var timediffFormat = "[" + PLACEHOLDER_TIMEDIFF + "]"
|
|
|
|
// current extras format (defaults to: "($EXTRAS$)")
|
|
var extrasFormat = "(" + PLACEHOLDER_EXTRAS + ")"
|
|
|
|
// current extras separator (defaults to: "|")
|
|
var extrasSeparator = "|"
|
|
|
|
// 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
|
|
}
|
|
|
|
// 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
|
|
}
|