mirror of
https://github.com/mjl-/mox.git
synced 2025-07-12 13:44:37 +03:00
allow unsetting a log level through subcommand and add admin page for settng log level
This commit is contained in:
@ -66,10 +66,10 @@ type AccountDestination struct {
|
||||
Destination config.Destination
|
||||
}
|
||||
|
||||
// SetLogLevel sets a new log level for pkg. An empty pkg sets the default log
|
||||
// LogLevelSet sets a new log level for pkg. An empty pkg sets the default log
|
||||
// value that is used if no explicit log level is configured for a package.
|
||||
// This change is ephemeral, no config file is changed.
|
||||
func (c *Config) SetLogLevel(pkg string, level mlog.Level) {
|
||||
func (c *Config) LogLevelSet(pkg string, level mlog.Level) {
|
||||
c.logMutex.Lock()
|
||||
defer c.logMutex.Unlock()
|
||||
l := c.copyLogLevels()
|
||||
@ -79,6 +79,17 @@ func (c *Config) SetLogLevel(pkg string, level mlog.Level) {
|
||||
mlog.SetConfig(c.Log)
|
||||
}
|
||||
|
||||
// LogLevelRemove removes a configured log level for a package.
|
||||
func (c *Config) LogLevelRemove(pkg string) {
|
||||
c.logMutex.Lock()
|
||||
defer c.logMutex.Unlock()
|
||||
l := c.copyLogLevels()
|
||||
delete(l, pkg)
|
||||
c.Log = l
|
||||
xlog.Print("log level cleared", mlog.Field("pkg", pkg))
|
||||
mlog.SetConfig(c.Log)
|
||||
}
|
||||
|
||||
// copyLogLevels returns a copy of c.Log, for modifications.
|
||||
// must be called with log lock held.
|
||||
func (c *Config) copyLogLevels() map[string]mlog.Level {
|
||||
|
Reference in New Issue
Block a user