update logger

This commit is contained in:
Adrian Zürcher
2025-04-22 17:59:07 +02:00
parent c21d9b0dd0
commit 274e6acf0e
3 changed files with 17 additions and 6 deletions

View File

@@ -5,6 +5,7 @@ import (
"artNet/models"
serverModels "artNet/server/models"
"fmt"
"path"
"github.com/tecamino/tecamino-logger/logging"
)
@@ -25,7 +26,13 @@ func NewDriver(cfgDir, name string, debug bool) (*ArtNetDriver, error) {
cfgDir = "./cfg"
}
logger, err := logging.NewLogger(name, debug)
logger, err := logging.NewLogger(path.Join(cfgDir, name+".log"), &logging.Config{
MaxSize: 1,
MaxBackup: 3,
MaxAge: 28,
Debug: debug,
TerminalOut: true,
})
if err != nil {
panic(err)
}
@@ -40,7 +47,7 @@ func NewDriver(cfgDir, name string, debug bool) (*ArtNetDriver, error) {
}
if err := d.LoadCfg(); err != nil {
logger.Error("artNet.NewDriver", "error load driver configuration: "+err.Error())
logger.Error("artNet.NewDriver.LoadCfg", "error load driver configuration: "+err.Error())
return nil, err
}
@@ -63,6 +70,7 @@ func (d *ArtNetDriver) LoadCfg() error {
// adds new Art-Net bus/interface to driver port 0 = 6454 (default art-net)
func (d *ArtNetDriver) NewBus(name, ip string, port int) *models.Bus {
b := models.NewBus(name, ip, port)
b.Start(d.Log)
d.Buses[name] = b
return b
}