This commit is contained in:
Gregory Salaun 2024-09-26 19:14:29 +07:00
parent c57258cc3a
commit 876682384e
3 changed files with 81 additions and 3 deletions

12
Dockerfile Normal file
View File

@ -0,0 +1,12 @@
FROM golang:1.23.1
WORKDIR /app
COPY go.mod go.sum ./
COPY clublog.go config.go config.yml database.go flexradio.go HTTPServer.go spot.go main.go TCPClient.go TCPServer.go utils.go log.go ./
COPY templates/* .
RUN go build -o bin main.go
ENTRYPOINT ["/app/bin"]

68
log.go Normal file
View File

@ -0,0 +1,68 @@
package main
import (
"io"
"os"
log "github.com/sirupsen/logrus"
prefixed "github.com/x-cray/logrus-prefixed-formatter"
)
func NewLog() *log.Logger {
// f, err := os.OpenFile("flexradio.log", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
// if err != nil {
// panic(err)
// }
// w := io.MultiWriter(os.Stdout, f)
w := io.Writer(os.Stdout)
l := &log.Logger{
Out: w,
Level: log.DebugLevel,
Formatter: &prefixed.TextFormatter{
DisableColors: false,
TimestampFormat: "02-01-2006 15:04:05",
FullTimestamp: true,
ForceFormatting: true,
},
}
l.Level = log.DebugLevel
return l
}
// Info ...
func Info(format string, v ...interface{}) {
log.Infof(format, v...)
}
// Warn ...
func Warn(format string, v ...interface{}) {
log.Warnf(format, v...)
}
// Error ...
func Error(format string, v ...interface{}) {
log.Errorf(format, v...)
}
func Debug(format string, v ...interface{}) {
log.Debugf(format, v...)
}
var (
// ConfigError ...
ConfigError = "%v type=config.error"
// HTTPError ...
HTTPError = "%v type=http.error"
// HTTPWarn ...
HTTPWarn = "%v type=http.warn"
// HTTPInfo ...
HTTPInfo = "%v type=http.info"
)

View File

@ -6,8 +6,6 @@ import (
"os"
"os/signal"
"syscall"
"git.rouggy.com/rouggy/FlexDXCluster/logger"
)
func ParseFlags() (string, error) {
@ -44,7 +42,7 @@ func main() {
log.Fatal(err)
}
log := logger.NewLog()
log := NewLog()
log.Info("config loaded.")
log.Infof("Callsign: %s", Cfg.SQLite.Callsign)