mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
Support for additional audit config via env var (#26785)
* Add support for additional audit config via env var
This commit is contained in:
parent
52ad3bd7b7
commit
2825ab689c
@ -4,10 +4,13 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
"os/user"
|
||||
"strings"
|
||||
|
||||
"github.com/mattermost/mattermost/server/public/model"
|
||||
"github.com/mattermost/mattermost/server/public/shared/mlog"
|
||||
@ -132,6 +135,16 @@ func (s *Server) configureAudit(adt *audit.Audit, bAllowAdvancedLogging bool) er
|
||||
return fmt.Errorf("invalid config for audit, %w", err)
|
||||
}
|
||||
|
||||
// Append additional config from env var; any target name collisions will be overwritten.
|
||||
additionalJSON := strings.TrimSpace(os.Getenv("MM_EXPERIMENTALAUDITSETTINGS_ADDITIONAL"))
|
||||
if additionalJSON != "" {
|
||||
cfgAdditional := make(mlog.LoggerConfiguration)
|
||||
if err := json.Unmarshal([]byte(additionalJSON), &cfgAdditional); err != nil {
|
||||
return fmt.Errorf("invalid additional config for audit, %w", err)
|
||||
}
|
||||
cfg.Append(cfgAdditional)
|
||||
}
|
||||
|
||||
return adt.Configure(cfg)
|
||||
}
|
||||
|
||||
|
@ -248,7 +248,7 @@ func (l *Logger) Configure(cfgFile string, cfgEscaped string, factories *Factori
|
||||
}
|
||||
|
||||
// ConfigureTargets provides a new configuration for this logger via a `LoggerConfig` map.
|
||||
// Typically `mlog.Configure` is used instead which accepts JSON formatted configuration.
|
||||
// `Logger.Configure` can be used instead which accepts JSON formatted configuration.
|
||||
// An optional set of factories can be provided which will be called to create any target
|
||||
// types or formatters not built-in.
|
||||
func (l *Logger) ConfigureTargets(cfg LoggerConfiguration, factories *Factories) error {
|
||||
|
Loading…
Reference in New Issue
Block a user