// 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() }