Skip to content

Commit

Permalink
Loglevel stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
lkarlslund committed Dec 15, 2023
1 parent b8f39b4 commit 08d311c
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions modules/ui/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,19 @@ const (
)

var (
defaultLogLevel = LevelInfo
clearneeded bool
logLevel = LevelInfo
clearneeded bool

Zerotime bool
starttime = time.Now()
)

func SetDefaultLoglevel(i LogLevel) {
defaultLogLevel = i
func SetLoglevel(i LogLevel) {
logLevel = i
}

func GetLoglevel() LogLevel {
return logLevel
}

var logfile *os.File
Expand Down Expand Up @@ -82,7 +86,7 @@ func (t Logger) Msgf(format string, args ...any) Logger {
if logfile != nil && logfilelevel <= t.ll {
fmt.Fprintf(logfile, timetext+" "+t.ll.String()+" "+format+"\n", args...)
}
if defaultLogLevel <= t.ll {
if logLevel <= t.ll {
if clearneeded {
pterm.Fprinto(t.pterm.Writer, strings.Repeat(" ", pterm.GetTerminalWidth()))
pterm.Fprinto(t.pterm.Writer)
Expand Down Expand Up @@ -111,7 +115,7 @@ func (t Logger) Msg(msg string) Logger {
}

func (t Logger) Err(e error) Logger {
if defaultLogLevel <= t.ll {
if logLevel <= t.ll {
t.Msgf("Error: %v", e.Error())
}
return t
Expand Down

0 comments on commit 08d311c

Please sign in to comment.