mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
* refactor utils/config* to config/ * pull validateLdapFilter into app * clean up Config/GetConfig/GetSanitizedConfig usage Eliminate app.GetConfig() in favour of just using app.Config() directly, but expose app.GetSanitizedConfig() for when the old behaviour was required. * web: isolate config setup * TestInvitePeopleProvider: make config explicit * regenerateClientConfig: avoid racey map access * integrate watch flag into app.ConfigFile option * make app.Option return an error * release.mk: only cp static files from config/ * release.mk: fix cp static files from config/ * api4: TestPlugin cleanup * s/c/cfg/ for clarity * fix merge conflict * testlib: allow customization of testlib driver name
49 lines
1.2 KiB
Go
49 lines
1.2 KiB
Go
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See License.txt for license information.
|
|
|
|
package utils
|
|
|
|
import (
|
|
"path/filepath"
|
|
"strings"
|
|
|
|
"github.com/mattermost/mattermost-server/mlog"
|
|
"github.com/mattermost/mattermost-server/model"
|
|
"github.com/mattermost/mattermost-server/utils/fileutils"
|
|
)
|
|
|
|
const (
|
|
LOG_ROTATE_SIZE = 10000
|
|
LOG_FILENAME = "mattermost.log"
|
|
)
|
|
|
|
func MloggerConfigFromLoggerConfig(s *model.LogSettings) *mlog.LoggerConfiguration {
|
|
return &mlog.LoggerConfiguration{
|
|
EnableConsole: *s.EnableConsole,
|
|
ConsoleJson: *s.ConsoleJson,
|
|
ConsoleLevel: strings.ToLower(*s.ConsoleLevel),
|
|
EnableFile: *s.EnableFile,
|
|
FileJson: *s.FileJson,
|
|
FileLevel: strings.ToLower(*s.FileLevel),
|
|
FileLocation: GetLogFileLocation(*s.FileLocation),
|
|
}
|
|
}
|
|
|
|
func GetLogFileLocation(fileLocation string) string {
|
|
if fileLocation == "" {
|
|
fileLocation, _ = fileutils.FindDir("logs")
|
|
}
|
|
|
|
return filepath.Join(fileLocation, LOG_FILENAME)
|
|
}
|
|
|
|
// DON'T USE THIS Modify the level on the app logger
|
|
func DisableDebugLogForTest() {
|
|
mlog.GloballyDisableDebugLogForTest()
|
|
}
|
|
|
|
// DON'T USE THIS Modify the level on the app logger
|
|
func EnableDebugLogForTest() {
|
|
mlog.GloballyEnableDebugLogForTest()
|
|
}
|