Multiple implementations of the same back-end application. The aim is to provide quick, side-by-side comparisons of different technologies (languages, frameworks, libraries) while preserving consistent business logic across all implementations.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

41 lines
935 B

package logging
import (
"context"
"io"
"log"
)
type StandardLogger struct {
logger *log.Logger
}
func NewStandardLogger(writer io.Writer) *StandardLogger {
return &StandardLogger{
logger: log.New(writer, "", log.LstdFlags),
}
}
func (l *StandardLogger) Info(ctx context.Context, msg string, fields ...interface{}) {
l.log("INFO", msg, fields...)
}
func (l *StandardLogger) Error(ctx context.Context, msg string, fields ...interface{}) {
l.log("ERROR", msg, fields...)
}
func (l *StandardLogger) Debug(ctx context.Context, msg string, fields ...interface{}) {
l.log("DEBUG", msg, fields...)
}
func (l *StandardLogger) Warn(ctx context.Context, msg string, fields ...interface{}) {
l.log("WARN", msg, fields...)
}
func (l *StandardLogger) log(level, msg string, fields ...interface{}) {
if len(fields) > 0 {
l.logger.Printf("[%s] %s %v", level, msg, fields)
} else {
l.logger.Printf("[%s] %s", level, msg)
}
}