mirror of
https://github.com/evilsocket/opensnitch.git
synced 2025-03-04 08:34:40 +01:00
log: fixed logging service
A default value was preventing from writing logs to the configured file. + Changed a couple of locks by rlocks.
This commit is contained in:
parent
2ad38fbf05
commit
e1afd24dbf
2 changed files with 17 additions and 17 deletions
|
@ -111,8 +111,8 @@ func Yellow(s string) string {
|
|||
|
||||
// Raw prints out a text without colors
|
||||
func Raw(format string, args ...interface{}) {
|
||||
mutex.Lock()
|
||||
defer mutex.Unlock()
|
||||
mutex.RLock()
|
||||
defer mutex.RUnlock()
|
||||
fmt.Fprintf(Output, format, args...)
|
||||
}
|
||||
|
||||
|
@ -125,40 +125,40 @@ func SetLogLevel(newLevel int) {
|
|||
|
||||
// GetLogLevel returns the current log level configured.
|
||||
func GetLogLevel() int {
|
||||
mutex.Lock()
|
||||
defer mutex.Unlock()
|
||||
mutex.RLock()
|
||||
defer mutex.RUnlock()
|
||||
|
||||
return MinLevel
|
||||
}
|
||||
|
||||
// SetLogUTC configures UTC timestamps
|
||||
func SetLogUTC(newLogUTC bool) {
|
||||
mutex.Lock()
|
||||
defer mutex.Unlock()
|
||||
LogUTC = newLogUTC
|
||||
mutex.Lock()
|
||||
defer mutex.Unlock()
|
||||
LogUTC = newLogUTC
|
||||
}
|
||||
|
||||
// GetLogUTC returns the current config.
|
||||
func GetLogUTC() bool {
|
||||
mutex.Lock()
|
||||
defer mutex.Unlock()
|
||||
mutex.RLock()
|
||||
defer mutex.RUnlock()
|
||||
|
||||
return LogUTC
|
||||
return LogUTC
|
||||
}
|
||||
|
||||
// SetLogMicro configures microsecond timestamps
|
||||
func SetLogMicro(newLogMicro bool) {
|
||||
mutex.Lock()
|
||||
defer mutex.Unlock()
|
||||
LogMicro = newLogMicro
|
||||
mutex.Lock()
|
||||
defer mutex.Unlock()
|
||||
LogMicro = newLogMicro
|
||||
}
|
||||
|
||||
// GetLogMicro returns the current config.
|
||||
func GetLogMicro() bool {
|
||||
mutex.Lock()
|
||||
defer mutex.Unlock()
|
||||
mutex.Lock()
|
||||
defer mutex.Unlock()
|
||||
|
||||
return LogMicro
|
||||
return LogMicro
|
||||
}
|
||||
|
||||
// Log prints out a text with the given color and format
|
||||
|
|
|
@ -115,7 +115,7 @@ func init() {
|
|||
}
|
||||
|
||||
func overwriteLogging() bool {
|
||||
return debug || warning || important || errorlog || logFile != "" || logUTC || logMicro
|
||||
return debug || warning || important || errorlog || logFile != "" || logMicro
|
||||
}
|
||||
|
||||
func setupLogging() {
|
||||
|
|
Loading…
Add table
Reference in a new issue