Structured logging (#8673)
* Implementing structured logging * Changes to en.json to allow refactor to run. * Fixing global logger * Structured logger initalization. * Add caller. * Do some log redirection. * Auto refactor * Cleaning up l4g reference and removing dependancy. * Removing junk. * Copyright headers. * Fixing tests * Revert "Changes to en.json to allow refactor to run." This reverts commit fd8249e99bcad0231e6ea65cd77c32aae9a54026. * Fixing some auto refactor strangeness and typo. * Making keys more human readable.
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
2acbc77d78
Коммит
686c2fbab7
@@ -5,6 +5,7 @@ package commands
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/mattermost/mattermost-server/app"
|
||||
"github.com/mattermost/mattermost-server/cmd"
|
||||
"github.com/mattermost/mattermost-server/model"
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"encoding/json"
|
||||
|
||||
"github.com/mattermost/mattermost-server/cmd"
|
||||
"github.com/mattermost/mattermost-server/utils"
|
||||
)
|
||||
|
||||
@@ -8,8 +8,8 @@ import (
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
l4g "github.com/alecthomas/log4go"
|
||||
"github.com/mattermost/mattermost-server/cmd"
|
||||
"github.com/mattermost/mattermost-server/mlog"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
@@ -36,13 +36,12 @@ func jobserverCmdF(command *cobra.Command, args []string) {
|
||||
if err != nil {
|
||||
panic(err.Error())
|
||||
}
|
||||
defer l4g.Close()
|
||||
defer a.Shutdown()
|
||||
|
||||
a.LoadLicense()
|
||||
|
||||
// Run jobs
|
||||
l4g.Info("Starting Mattermost job server")
|
||||
mlog.Info("Starting Mattermost job server")
|
||||
if !noJobs {
|
||||
a.Jobs.StartWorkers()
|
||||
}
|
||||
@@ -55,10 +54,10 @@ func jobserverCmdF(command *cobra.Command, args []string) {
|
||||
<-signalChan
|
||||
|
||||
// Cleanup anything that isn't handled by a defer statement
|
||||
l4g.Info("Stopping Mattermost job server")
|
||||
mlog.Info("Stopping Mattermost job server")
|
||||
|
||||
a.Jobs.StopSchedulers()
|
||||
a.Jobs.StopWorkers()
|
||||
|
||||
l4g.Info("Stopped Mattermost job server")
|
||||
mlog.Info("Stopped Mattermost job server")
|
||||
}
|
||||
|
||||
@@ -4,18 +4,19 @@
|
||||
package commands
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
l4g "github.com/alecthomas/log4go"
|
||||
"github.com/mattermost/mattermost-server/api"
|
||||
"github.com/mattermost/mattermost-server/api4"
|
||||
"github.com/mattermost/mattermost-server/app"
|
||||
"github.com/mattermost/mattermost-server/cmd"
|
||||
"github.com/mattermost/mattermost-server/manualtesting"
|
||||
"github.com/mattermost/mattermost-server/mlog"
|
||||
"github.com/mattermost/mattermost-server/model"
|
||||
"github.com/mattermost/mattermost-server/utils"
|
||||
"github.com/mattermost/mattermost-server/web"
|
||||
@@ -61,7 +62,7 @@ func runServer(configFileLocation string, disableConfigWatch bool, interruptChan
|
||||
|
||||
a, err := app.New(options...)
|
||||
if err != nil {
|
||||
l4g.Critical(err.Error())
|
||||
mlog.Critical(err.Error())
|
||||
return err
|
||||
}
|
||||
defer a.Shutdown()
|
||||
@@ -69,17 +70,17 @@ func runServer(configFileLocation string, disableConfigWatch bool, interruptChan
|
||||
utils.TestConnection(a.Config())
|
||||
|
||||
pwd, _ := os.Getwd()
|
||||
l4g.Info(utils.T("mattermost.current_version"), model.CurrentVersion, model.BuildNumber, model.BuildDate, model.BuildHash, model.BuildHashEnterprise)
|
||||
l4g.Info(utils.T("mattermost.entreprise_enabled"), model.BuildEnterpriseReady)
|
||||
l4g.Info(utils.T("mattermost.working_dir"), pwd)
|
||||
l4g.Info(utils.T("mattermost.config_file"), utils.FindConfigFile(configFileLocation))
|
||||
mlog.Info(fmt.Sprintf("Current version is %v (%v/%v/%v/%v)", model.CurrentVersion, model.BuildNumber, model.BuildDate, model.BuildHash, model.BuildHashEnterprise))
|
||||
mlog.Info(fmt.Sprintf("Enterprise Enabled: %v", model.BuildEnterpriseReady))
|
||||
mlog.Info(fmt.Sprintf("Current working directory is %v", pwd))
|
||||
mlog.Info(fmt.Sprintf("Loaded config file from %v", utils.FindConfigFile(configFileLocation)))
|
||||
|
||||
backend, appErr := a.FileBackend()
|
||||
if appErr == nil {
|
||||
appErr = backend.TestConnection()
|
||||
}
|
||||
if appErr != nil {
|
||||
l4g.Error("Problem with file storage settings: " + appErr.Error())
|
||||
mlog.Error("Problem with file storage settings: " + appErr.Error())
|
||||
}
|
||||
|
||||
if model.BuildEnterpriseReady == "true" {
|
||||
@@ -99,7 +100,7 @@ func runServer(configFileLocation string, disableConfigWatch bool, interruptChan
|
||||
|
||||
serverErr := a.StartServer()
|
||||
if serverErr != nil {
|
||||
l4g.Critical(serverErr.Error())
|
||||
mlog.Critical(serverErr.Error())
|
||||
return serverErr
|
||||
}
|
||||
|
||||
@@ -111,7 +112,7 @@ func runServer(configFileLocation string, disableConfigWatch bool, interruptChan
|
||||
license := a.License()
|
||||
|
||||
if license == nil && len(a.Config().SqlSettings.DataSourceReplicas) > 1 {
|
||||
l4g.Warn(utils.T("store.sql.read_replicas_not_licensed.critical"))
|
||||
mlog.Warn("More than 1 read replica functionality disabled by current license. Please contact your system administrator about upgrading your enterprise license.")
|
||||
a.UpdateConfig(func(cfg *model.Config) {
|
||||
cfg.SqlSettings.DataSourceReplicas = cfg.SqlSettings.DataSourceReplicas[:1]
|
||||
})
|
||||
@@ -171,7 +172,7 @@ func runServer(configFileLocation string, disableConfigWatch bool, interruptChan
|
||||
if a.Elasticsearch != nil {
|
||||
a.Go(func() {
|
||||
if err := a.Elasticsearch.Start(); err != nil {
|
||||
l4g.Error(err.Error())
|
||||
mlog.Error(err.Error())
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -241,7 +242,7 @@ func runSessionCleanupJob(a *app.App) {
|
||||
|
||||
func resetStatuses(a *app.App) {
|
||||
if result := <-a.Srv.Store.Status().ResetAll(); result.Err != nil {
|
||||
l4g.Error(utils.T("mattermost.reset_status.error"), result.Err.Error())
|
||||
mlog.Error(fmt.Sprint("mattermost.reset_status.error FIXME: NOT FOUND IN TRANSLATIONS FILE", result.Err.Error()))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -260,11 +261,11 @@ func notifyReady() {
|
||||
// notify systemd that the server is ready.
|
||||
systemdSocket := os.Getenv("NOTIFY_SOCKET")
|
||||
if systemdSocket != "" {
|
||||
l4g.Info("Sending systemd READY notification.")
|
||||
mlog.Info("Sending systemd READY notification.")
|
||||
|
||||
err := sendSystemdReadyNotification(systemdSocket)
|
||||
if err != nil {
|
||||
l4g.Error(err.Error())
|
||||
mlog.Error(err.Error())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
|
||||
l4g "github.com/alecthomas/log4go"
|
||||
"github.com/mattermost/mattermost-server/app"
|
||||
"github.com/mattermost/mattermost-server/cmd"
|
||||
"github.com/mattermost/mattermost-server/model"
|
||||
@@ -644,7 +643,7 @@ func migrateAuthToSamlCmdF(command *cobra.Command, args []string) error {
|
||||
if err := migrate.MigrateToSaml(fromAuth, matches, autoFlag, dryRunFlag); err != nil {
|
||||
return errors.New("Error while migrating users: " + err.Error())
|
||||
}
|
||||
l4g.Close()
|
||||
|
||||
cmd.CommandPrettyPrintln("Successfully migrated accounts.")
|
||||
}
|
||||
|
||||
|
||||
@@ -33,8 +33,6 @@ func InitDBCommandContext(configFileLocation string) (*app.App, error) {
|
||||
}
|
||||
model.AppErrorInit(utils.T)
|
||||
|
||||
utils.ConfigureCmdLineLog()
|
||||
|
||||
a, err := app.New(app.ConfigFile(configFileLocation))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
Ссылка в новой задаче
Block a user