File tree Expand file tree Collapse file tree 2 files changed +10
-7
lines changed
Expand file tree Collapse file tree 2 files changed +10
-7
lines changed Original file line number Diff line number Diff line change 11package loggerbase
22
33import (
4- "fmt"
54 "os"
65 "path"
76 "sync/atomic"
87 "time"
98
9+ trace "github.com/rs/zerolog/log"
10+
1011 "github.com/HyperloopUPV-H8/h9-backend/pkg/abstraction"
1112 loggerHandler "github.com/HyperloopUPV-H8/h9-backend/pkg/logger"
1213 "github.com/HyperloopUPV-H8/h9-backend/pkg/transport/packet/data"
@@ -42,13 +43,13 @@ type BaseLogger struct {
4243// Function to start the base logger
4344func (sublogger * BaseLogger ) Start () error {
4445 if ! sublogger .Running .CompareAndSwap (false , true ) {
45- fmt . Println ("Logger already running" )
46+ trace . Warn (). Msg ("Logger already running" )
4647 return nil
4748 }
4849
4950 sublogger .StartTime = loggerHandler .FormatTimestamp (time .Now ()) // Update the start time
5051
51- fmt . Println ( "Logger started " + string (sublogger .Name ) + "." )
52+ trace . Info (). Msg ( "Logger " + string (sublogger .Name ) + " started ." )
5253 return nil
5354}
5455
@@ -92,12 +93,12 @@ func (sublogger *BaseLogger) PullRecord(abstraction.LoggerRequest) (abstraction.
9293// Param templateStop is a function that contains the specific stop actions of each logger
9394func (sublogger * BaseLogger ) Stop (templateStop func () error ) error {
9495 if ! sublogger .Running .CompareAndSwap (true , false ) {
95- fmt . Println ("Logger already stopped" + string (sublogger .Name ) + "." )
96+ trace . Warn (). Msg ("Logger already stopped" + string (sublogger .Name ) + "." )
9697 return nil
9798 }
9899
99100 output := templateStop ()
100101
101- fmt . Println ( "Logger stopped " + string (sublogger .Name ) + "." )
102+ trace . Info (). Msg ( "Logger " + string (sublogger .Name ) + " stopped ." )
102103 return output
103104}
Original file line number Diff line number Diff line change 77 "time"
88
99 loggerbase "github.com/HyperloopUPV-H8/h9-backend/pkg/logger/base"
10+ trace "github.com/rs/zerolog/log"
1011
1112 "github.com/HyperloopUPV-H8/h9-backend/pkg/abstraction"
1213 "github.com/HyperloopUPV-H8/h9-backend/pkg/logger"
@@ -40,7 +41,8 @@ func NewLogger() *Logger {
4041func (sublogger * Logger ) Start () error {
4142
4243 if ! sublogger .Running .CompareAndSwap (false , true ) {
43- fmt .Println ("Logger already running" )
44+
45+ trace .Warn ().Msg ("Logger already running" )
4446 return nil
4547 }
4648 // Create the file for logging, if the logger was already running
@@ -52,7 +54,7 @@ func (sublogger *Logger) Start() error {
5254 sublogger .StartTime = logger .FormatTimestamp (time .Now ()) // Update the start time
5355
5456 sublogger .writer = file .NewCSV (fileRaw )
55- fmt . Println ( "Logger started " + string (sublogger .Name ) + "." )
57+ trace . Info (). Msg ( "Logger " + string (sublogger .Name ) + " started ." )
5658 return nil
5759}
5860
You can’t perform that action at this time.
0 commit comments