diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..947f44f --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module portale-stac.it/packages/logger + +go 1.18 diff --git a/logger.go b/logger.go new file mode 100644 index 0000000..3950c16 --- /dev/null +++ b/logger.go @@ -0,0 +1,48 @@ +// setup.go +package logger + +import "io/fs" + +const ( + LOGGER_MAX_MESSAGE_LENGTH = iota + 1 + + IMPLEMENTATION_PROPERTY_BASE_ID = 100 +) + +type Logger interface { + Debugf(templ string, args ...any) +} + +type FullLogger interface { + Logger + IsDebugEnabled() bool + IsInfoEnabled() bool + DebugRawb(msg []byte) + Dumpf(data []byte, perm fs.FileMode, templ string, args ...any) (dumpFilePath string) + DebugRawf(templ string, args ...any) + InfoRawf(templ string, args ...any) + WarnRawf(templ string, args ...any) + ErrorRawf(templ string, args ...any) + Infof(templ string, args ...any) + Warnf(templ string, args ...any) + Errorf(templ string, args ...any) + OobLogf(templ string, args ...any) + + SetRotation(maxSize int64, rotateNumber int) + Finalize() + SetProperty(propertyId int, value any) (success bool) + GetProperty(propertyId int) (value any) + GetPropertyBool(propertyId int) (value bool, ok bool) +} + +type VerboseLogger interface { + FullLogger + VerboseRedf(templ string, args ...any) string + VerboseGreenf(templ string, args ...any) string + VerboseBluef(templ string, args ...any) string + VerboseBrownf(templ string, args ...any) string +} + +type NullLogger struct{} + +func (self *NullLogger) Debugf(templ string, args ...any) {} diff --git a/setup.go b/setup.go new file mode 100644 index 0000000..08e66f1 --- /dev/null +++ b/setup.go @@ -0,0 +1,8 @@ +// setup.go +package logger + +var LOG Logger = nil + +func Setup(l Logger) { + LOG = l +}