initialize paraclub-ai-mailer project with core components and configuration

This commit is contained in:
2025-03-01 00:32:27 +01:00
commit 34c35c395f
11 changed files with 848 additions and 0 deletions

58
internal/logger/logger.go Normal file
View File

@@ -0,0 +1,58 @@
package logger
import (
"io"
"os"
"github.com/sirupsen/logrus"
)
var log = logrus.New()
func Init(level string, filePath string) error {
// Set log level
lvl, err := logrus.ParseLevel(level)
if err != nil {
return err
}
log.SetLevel(lvl)
// Configure output
if filePath != "" {
file, err := os.OpenFile(filePath, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666)
if err != nil {
return err
}
log.SetOutput(io.MultiWriter(os.Stdout, file))
}
log.SetFormatter(&logrus.TextFormatter{
FullTimestamp: true,
})
return nil
}
func Info(args ...interface{}) {
log.Info(args...)
}
func Error(args ...interface{}) {
log.Error(args...)
}
func Debug(args ...interface{}) {
log.Debug(args...)
}
func Warn(args ...interface{}) {
log.Warn(args...)
}
func WithField(key string, value interface{}) *logrus.Entry {
return log.WithField(key, value)
}
func WithFields(fields logrus.Fields) *logrus.Entry {
return log.WithFields(fields)
}