-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reworked service lockfile to use 'flock' syscall (cf. uhppoted/uhppot…
- Loading branch information
Showing
5 changed files
with
112 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package log | ||
|
||
import ( | ||
"fmt" | ||
syslog "log" | ||
|
||
"github.com/uhppoted/uhppoted-lib/log" | ||
) | ||
|
||
type LogLevel int | ||
|
||
const ( | ||
none LogLevel = iota | ||
debug | ||
info | ||
warn | ||
errors | ||
) | ||
|
||
const f = "%-12v %v" | ||
|
||
func SetDebug(enabled bool) { | ||
log.SetDebug(enabled) | ||
} | ||
|
||
func SetLevel(level string) { | ||
log.SetLevel(level) | ||
} | ||
|
||
func SetLogger(logger *syslog.Logger) { | ||
log.SetLogger(logger) | ||
} | ||
|
||
func AddFatalHook(f func()) { | ||
log.AddFatalHook(f) | ||
} | ||
|
||
func Debugf(tag string, format string, args ...any) { | ||
s := fmt.Sprintf(f, tag, format) | ||
|
||
log.Debugf(s, args...) | ||
} | ||
|
||
func Infof(tag string, format string, args ...any) { | ||
s := fmt.Sprintf(f, tag, format) | ||
|
||
log.Infof(s, args...) | ||
} | ||
|
||
func Warnf(tag string, format string, args ...any) { | ||
s := fmt.Sprintf(f, tag, format) | ||
|
||
log.Warnf(s, args...) | ||
} | ||
|
||
func Errorf(tag string, format string, args ...any) { | ||
s := fmt.Sprintf(f, tag, format) | ||
|
||
log.Errorf(s, args...) | ||
} | ||
|
||
func Fatalf(tag string, format string, args ...any) { | ||
s := fmt.Sprintf(f, tag, format) | ||
|
||
log.Fatalf(s, args...) | ||
} |