diff options
author | Christopher Speller <crspeller@gmail.com> | 2018-04-27 12:49:45 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-27 12:49:45 -0700 |
commit | 686c2fbab7607d42183ae685a27ea3d7dce8c3f6 (patch) | |
tree | 53ed73cada57bc43f342ac10e2f842cddb095218 /utils/redirect_std_log.go | |
parent | 2acbc77d78456d7ba76ceb687b18985d7d92f814 (diff) | |
download | chat-686c2fbab7607d42183ae685a27ea3d7dce8c3f6.tar.gz chat-686c2fbab7607d42183ae685a27ea3d7dce8c3f6.tar.bz2 chat-686c2fbab7607d42183ae685a27ea3d7dce8c3f6.zip |
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.
Diffstat (limited to 'utils/redirect_std_log.go')
-rw-r--r-- | utils/redirect_std_log.go | 65 |
1 files changed, 0 insertions, 65 deletions
diff --git a/utils/redirect_std_log.go b/utils/redirect_std_log.go deleted file mode 100644 index 4fbfcf8ec..000000000 --- a/utils/redirect_std_log.go +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved. -// See License.txt for license information. - -package utils - -import ( - "bufio" - "log" - "os" - "strings" - - l4g "github.com/alecthomas/log4go" -) - -type RedirectStdLog struct { - reader *os.File - writer *os.File - system string - ignoreDebug bool -} - -func NewRedirectStdLog(system string, ignoreDebug bool) *log.Logger { - r, w, _ := os.Pipe() - logger := &RedirectStdLog{ - reader: r, - writer: w, - system: system, - ignoreDebug: ignoreDebug, - } - - go func(l *RedirectStdLog) { - scanner := bufio.NewScanner(l.reader) - for scanner.Scan() { - line := scanner.Text() - - if strings.Index(line, "[DEBUG]") == 0 { - if !ignoreDebug { - l4g.Debug("%v%v", system, line[7:]) - } - } else if strings.Index(line, "[DEBG]") == 0 { - if !ignoreDebug { - l4g.Debug("%v%v", system, line[6:]) - } - } else if strings.Index(line, "[WARN]") == 0 { - l4g.Info("%v%v", system, line[6:]) - } else if strings.Index(line, "[ERROR]") == 0 { - l4g.Error("%v%v", system, line[7:]) - } else if strings.Index(line, "[EROR]") == 0 { - l4g.Error("%v%v", system, line[6:]) - } else if strings.Index(line, "[ERR]") == 0 { - l4g.Error("%v%v", system, line[5:]) - } else if strings.Index(line, "[INFO]") == 0 { - l4g.Info("%v%v", system, line[6:]) - } else { - l4g.Info("%v %v", system, line) - } - } - }(logger) - - return log.New(logger.writer, "", 0) -} - -func (l *RedirectStdLog) Write(p []byte) (n int, err error) { - return l.writer.Write(p) -} |