update
This commit is contained in:
parent
c57258cc3a
commit
876682384e
12
Dockerfile
Normal file
12
Dockerfile
Normal 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
68
log.go
Normal 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"
|
||||||
|
)
|
4
main.go
4
main.go
@ -6,8 +6,6 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"git.rouggy.com/rouggy/FlexDXCluster/logger"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func ParseFlags() (string, error) {
|
func ParseFlags() (string, error) {
|
||||||
@ -44,7 +42,7 @@ func main() {
|
|||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
log := logger.NewLog()
|
log := NewLog()
|
||||||
|
|
||||||
log.Info("config loaded.")
|
log.Info("config loaded.")
|
||||||
log.Infof("Callsign: %s", Cfg.SQLite.Callsign)
|
log.Infof("Callsign: %s", Cfg.SQLite.Callsign)
|
||||||
|
Loading…
Reference in New Issue
Block a user