README update and missing dependencies.
This commit is contained in:
1
vendor/github.com/pztrn/mogrus/.gitignore
generated
vendored
Normal file
1
vendor/github.com/pztrn/mogrus/.gitignore
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
*DS_Store*
|
3
vendor/github.com/pztrn/mogrus/.travis.yml
generated
vendored
Normal file
3
vendor/github.com/pztrn/mogrus/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
language: go
|
||||
go:
|
||||
- "1.10"
|
30
vendor/github.com/pztrn/mogrus/Gopkg.lock
generated
vendored
Normal file
30
vendor/github.com/pztrn/mogrus/Gopkg.lock
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
|
||||
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/sirupsen/logrus"
|
||||
packages = ["."]
|
||||
revision = "d682213848ed68c0a260ca37d6dd5ace8423f5ba"
|
||||
version = "v1.0.4"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "golang.org/x/crypto"
|
||||
packages = ["ssh/terminal"]
|
||||
revision = "3d37316aaa6bd9929127ac9a527abf408178ea7b"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "golang.org/x/sys"
|
||||
packages = [
|
||||
"unix",
|
||||
"windows"
|
||||
]
|
||||
revision = "03467258950d845cd1877eab69461b98e8c09219"
|
||||
|
||||
[solve-meta]
|
||||
analyzer-name = "dep"
|
||||
analyzer-version = 1
|
||||
inputs-digest = "97f3cd8b7a00b2b98fe58f834cf0d2f2c840a89809d15b451fdde156324ba6b1"
|
||||
solver-name = "gps-cdcl"
|
||||
solver-version = 1
|
25
vendor/github.com/pztrn/mogrus/Gopkg.toml
generated
vendored
Normal file
25
vendor/github.com/pztrn/mogrus/Gopkg.toml
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
# Gopkg.toml example
|
||||
#
|
||||
# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md
|
||||
# for detailed Gopkg.toml documentation.
|
||||
#
|
||||
# required = ["github.com/user/thing/cmd/thing"]
|
||||
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
|
||||
#
|
||||
# [[constraint]]
|
||||
# name = "github.com/user/project"
|
||||
# version = "1.0.0"
|
||||
#
|
||||
# [[constraint]]
|
||||
# name = "github.com/user/project2"
|
||||
# branch = "dev"
|
||||
# source = "github.com/myfork/project2"
|
||||
#
|
||||
# [[override]]
|
||||
# name = "github.com/x/y"
|
||||
# version = "2.4.0"
|
||||
|
||||
|
||||
[[constraint]]
|
||||
name = "github.com/sirupsen/logrus"
|
||||
version = "1.0.4"
|
7
vendor/github.com/pztrn/mogrus/LICENSE
generated
vendored
Normal file
7
vendor/github.com/pztrn/mogrus/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
Copyright 2017-2018, Stanislav N. aka pztrn
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
48
vendor/github.com/pztrn/mogrus/README.md
generated
vendored
Normal file
48
vendor/github.com/pztrn/mogrus/README.md
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
[](https://godoc.org/github.com/pztrn/mogrus) [](https://travis-ci.org/pztrn/mogrus)
|
||||
|
||||
# Mogrus
|
||||
|
||||
Logger thing built on top of github.com/sirupsen/logrus with ability to
|
||||
create multiple loggers (e.g. console and file loggers) for one logger
|
||||
instance.
|
||||
|
||||
The reason to create this handler was a need of logging things to both
|
||||
console and, e.g., file, which is unsupported by logrus itself (you have
|
||||
to create several loggers for each output).
|
||||
|
||||
## Example
|
||||
|
||||
```
|
||||
package main
|
||||
|
||||
import (
|
||||
// stdlib
|
||||
"os"
|
||||
|
||||
// tools
|
||||
"github.com/pztrn/mogrus"
|
||||
)
|
||||
|
||||
func main() {
|
||||
l := mogrus.New()
|
||||
l.Initialize()
|
||||
log := l.CreateLogger("helloworld")
|
||||
log.CreateOutput("stdout", os.Stdout, true, "debug")
|
||||
|
||||
// File output.
|
||||
file_output, err := os.Create("/tmp/hellorowld.log")
|
||||
if err != nil {
|
||||
log.Errorln("Failed to create file output:", err.Error())
|
||||
}
|
||||
log.CreateOutput("file /tmp/hellorowld.log", file_output, false)
|
||||
|
||||
log.Println("Starting log experiment tool...")
|
||||
log.Debugln("Debug here!")
|
||||
log.Infoln("This is INFO level")
|
||||
log.Println("This is also INFO level.")
|
||||
log.Warnln("This is WARN.")
|
||||
log.Errorln("This is ERROR level.")
|
||||
log.Fatalln("We will exit here.")
|
||||
}
|
||||
|
||||
```
|
45
vendor/github.com/pztrn/mogrus/doc.go
generated
vendored
Normal file
45
vendor/github.com/pztrn/mogrus/doc.go
generated
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
// Copyright (c) 2017-2018, Stanislav N. aka pztrn.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject
|
||||
// to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
||||
// OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
package mogrus
|
||||
|
||||
// Mogrus is a logger package built on top of Logrus with extended
|
||||
// (and kinda simplified) approach for multilogging.
|
||||
//
|
||||
// Example usage:
|
||||
//
|
||||
// TBF
|
||||
//
|
||||
// Output functions are splitted in three things:
|
||||
// * ``Debug`` - simple debug printing
|
||||
// * ``Debugf`` - debug printing with line formatting
|
||||
// * ``Debugln`` - debug printing, same as Debug().
|
||||
//
|
||||
// It will try to resemble Logrus as much as possible.
|
||||
//
|
||||
// About functions.
|
||||
//
|
||||
// Info(f,ln) and Print(f,ln) doing same thing - logging to
|
||||
// INFO log level.
|
||||
//
|
||||
// Be careful while using Fatal(f,ln) functions, because
|
||||
// it will log only to first logger and then will os.Exit(1)!
|
||||
// There is no guarantee what logger will be first ATM.
|
55
vendor/github.com/pztrn/mogrus/doc/logging_to_mattermost.md
generated
vendored
Normal file
55
vendor/github.com/pztrn/mogrus/doc/logging_to_mattermost.md
generated
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
This example presumes:
|
||||
|
||||
1. You're using mogrus as logger.
|
||||
|
||||
2. You want to log messages from something to Mattermost.
|
||||
|
||||
3. You have ``SendMessage(channelID string, msg string)`` in your Mattermost's
|
||||
client library for sending messages to desired channel.
|
||||
|
||||
4. ``cl.DebugChannelID is`` a channel ID to which mogrus will log.
|
||||
|
||||
Here's io.Writer-compatible struct for using with mogrus:
|
||||
|
||||
```
|
||||
var logMessage = `Level: %s
|
||||
Timestamp: %s
|
||||
|
||||
%s`
|
||||
|
||||
// MattermostChannelLogger provides io.Writer compatible interface for
|
||||
// writing logs to Mattermost channel.
|
||||
type MattermostChannelLogger struct{}
|
||||
|
||||
func (mcl MattermostChannelLogger) Write(p []byte) (n int, err error) {
|
||||
// Generate eye-candy message.
|
||||
pstr := string(p)
|
||||
|
||||
timer := regexp.MustCompile("time=\"([0-9. -:]+)\"")
|
||||
timeFound := timer.FindAllStringSubmatch(pstr, -1)
|
||||
time := timeFound[0][1]
|
||||
|
||||
levelr := regexp.MustCompile("level=([a-zA-Z]+)")
|
||||
levelFound := levelr.FindAllStringSubmatch(pstr, -1)
|
||||
level := levelFound[0][1]
|
||||
|
||||
msgr := regexp.MustCompile("msg=\"(.+)\"")
|
||||
msgFound := msgr.FindAllStringSubmatch(pstr, -1)
|
||||
logmsg := msgFound[0][1]
|
||||
|
||||
msg := fmt.Sprintf(logMessage, level, time, logmsg)
|
||||
|
||||
cl.SendMessage(cl.DebugChannelID, msg)
|
||||
|
||||
return len(p), nil
|
||||
}
|
||||
```
|
||||
|
||||
Initialize it after connecting to Mattermost server like:
|
||||
|
||||
```
|
||||
// Register output for logging into Mattermost's channel.
|
||||
c.Log.CreateOutput("Mattermost debug channel", MattermostChannelLogger{}, false, cfg.System.Logging.Level)
|
||||
```
|
||||
|
||||
Where ``c.Log`` is a mogrus instance, ``cfg.System.Logging.Level`` is one of logging levels ("debug", "info", "warn" or "error").
|
26
vendor/github.com/pztrn/mogrus/exported.go
generated
vendored
Normal file
26
vendor/github.com/pztrn/mogrus/exported.go
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
// Copyright (c) 2017-2018, Stanislav N. aka pztrn.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject
|
||||
// to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
||||
// OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
package mogrus
|
||||
|
||||
// New creates new Mogrus Logger and returns it's pointer to caller.
|
||||
func New() *MogrusLogger {
|
||||
return &MogrusLogger{}
|
||||
}
|
270
vendor/github.com/pztrn/mogrus/handler.go
generated
vendored
Normal file
270
vendor/github.com/pztrn/mogrus/handler.go
generated
vendored
Normal file
@@ -0,0 +1,270 @@
|
||||
// Copyright (c) 2017-2018, Stanislav N. aka pztrn.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject
|
||||
// to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
||||
// OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
package mogrus
|
||||
|
||||
import (
|
||||
// stdlib
|
||||
"io"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
// github
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
type LoggerHandler struct {
|
||||
// Logrus instances
|
||||
instances map[string]*logrus.Logger
|
||||
instancesMutex sync.Mutex
|
||||
}
|
||||
|
||||
// CreateOutput adds output for logger handler.
|
||||
// This actually creates new Logrus's Logger instance and configure
|
||||
// it to write to given writer.
|
||||
// To configure debug level you should pass it's name as debugLvl.
|
||||
// Valid values: "", "debug" (the default), "info", "warn", "error"
|
||||
func (lh *LoggerHandler) CreateOutput(name string, writer io.Writer, colors bool, debugLvl string) {
|
||||
// Formatter.
|
||||
logrus_formatter := new(logrus.TextFormatter)
|
||||
logrus_formatter.DisableTimestamp = false
|
||||
logrus_formatter.FullTimestamp = true
|
||||
logrus_formatter.QuoteEmptyFields = true
|
||||
logrus_formatter.TimestampFormat = "2006-01-02 15:04:05.000000000"
|
||||
|
||||
if colors {
|
||||
logrus_formatter.DisableColors = false
|
||||
logrus_formatter.ForceColors = true
|
||||
} else {
|
||||
logrus_formatter.DisableColors = true
|
||||
logrus_formatter.ForceColors = false
|
||||
}
|
||||
|
||||
logrus_instance := logrus.New()
|
||||
logrus_instance.Out = writer
|
||||
// Defaulting to debug.
|
||||
logrus_instance.Level = logrus.DebugLevel
|
||||
if debugLvl == "info" {
|
||||
logrus_instance.Level = logrus.InfoLevel
|
||||
} else if debugLvl == "warn" {
|
||||
logrus_instance.Level = logrus.WarnLevel
|
||||
} else if debugLvl == "error" {
|
||||
logrus_instance.Level = logrus.ErrorLevel
|
||||
}
|
||||
logrus_instance.Formatter = logrus_formatter
|
||||
|
||||
lh.instancesMutex.Lock()
|
||||
lh.instances[name] = logrus_instance
|
||||
|
||||
for _, logger := range lh.instances {
|
||||
logger.Debugln("Added new logger output:", name)
|
||||
}
|
||||
lh.instancesMutex.Unlock()
|
||||
}
|
||||
|
||||
// FormatString formats string by replacing "{{ var }}"'s with data from
|
||||
// passed map.
|
||||
func (lh *LoggerHandler) FormatString(data string, replacers map[string]string) string {
|
||||
for k, v := range replacers {
|
||||
data = strings.Replace(data, "{{ "+k+" }}", v, -1)
|
||||
}
|
||||
|
||||
return data
|
||||
}
|
||||
|
||||
// Initialize initializes logger handler.
|
||||
// It will only initializes LoggerHandler structure, see CreateOutput()
|
||||
// for configuring output for this logger handler.
|
||||
func (lh *LoggerHandler) Initialize() {
|
||||
lh.instances = make(map[string]*logrus.Logger)
|
||||
}
|
||||
|
||||
// RemoveOutput removes previously created output.
|
||||
// If output isn't found - doing nothing.
|
||||
func (lh *LoggerHandler) RemoveOutput(output_name string) {
|
||||
lh.instancesMutex.Lock()
|
||||
_, found := lh.instances[output_name]
|
||||
if found {
|
||||
delete(lh.instances, output_name)
|
||||
}
|
||||
lh.instancesMutex.Unlock()
|
||||
}
|
||||
|
||||
// Proxy for Logrus's Logger.Debug() function.
|
||||
func (lh *LoggerHandler) Debug(args ...interface{}) {
|
||||
lh.instancesMutex.Lock()
|
||||
for _, logger := range lh.instances {
|
||||
logger.Debug(args...)
|
||||
}
|
||||
lh.instancesMutex.Unlock()
|
||||
}
|
||||
|
||||
// Proxy for Logrus's Logger.Debugf() function.
|
||||
func (lh *LoggerHandler) Debugf(format string, args ...interface{}) {
|
||||
lh.instancesMutex.Lock()
|
||||
for _, logger := range lh.instances {
|
||||
logger.Debugf(format, args...)
|
||||
}
|
||||
lh.instancesMutex.Unlock()
|
||||
}
|
||||
|
||||
// Proxy for Logrus's Logger.Debugln() function.
|
||||
func (lh *LoggerHandler) Debugln(args ...interface{}) {
|
||||
lh.instancesMutex.Lock()
|
||||
for _, logger := range lh.instances {
|
||||
logger.Debugln(args...)
|
||||
}
|
||||
lh.instancesMutex.Unlock()
|
||||
}
|
||||
|
||||
// Proxy for Logrus's Logger.Error() function.
|
||||
func (lh *LoggerHandler) Error(args ...interface{}) {
|
||||
lh.instancesMutex.Lock()
|
||||
for _, logger := range lh.instances {
|
||||
logger.Error(args...)
|
||||
}
|
||||
lh.instancesMutex.Unlock()
|
||||
}
|
||||
|
||||
// Proxy for Logrus's Logger.Errorf() function.
|
||||
func (lh *LoggerHandler) Errorf(format string, args ...interface{}) {
|
||||
lh.instancesMutex.Lock()
|
||||
for _, logger := range lh.instances {
|
||||
logger.Errorf(format, args...)
|
||||
}
|
||||
lh.instancesMutex.Unlock()
|
||||
}
|
||||
|
||||
// Proxy for Logrus's Logger.Errorln() function.
|
||||
func (lh *LoggerHandler) Errorln(args ...interface{}) {
|
||||
lh.instancesMutex.Lock()
|
||||
for _, logger := range lh.instances {
|
||||
logger.Errorln(args...)
|
||||
}
|
||||
lh.instancesMutex.Unlock()
|
||||
}
|
||||
|
||||
// Proxy for Logrus's Logger.Fatal() function.
|
||||
func (lh *LoggerHandler) Fatal(args ...interface{}) {
|
||||
lh.instancesMutex.Lock()
|
||||
for _, logger := range lh.instances {
|
||||
logger.Fatal(args...)
|
||||
}
|
||||
lh.instancesMutex.Unlock()
|
||||
}
|
||||
|
||||
// Proxy for Logrus's Logger.Fatalf() function.
|
||||
func (lh *LoggerHandler) Fatalf(format string, args ...interface{}) {
|
||||
lh.instancesMutex.Lock()
|
||||
for _, logger := range lh.instances {
|
||||
logger.Fatalf(format, args...)
|
||||
}
|
||||
lh.instancesMutex.Unlock()
|
||||
}
|
||||
|
||||
// Proxy for Logrus's Logger.Fatalln() function.
|
||||
func (lh *LoggerHandler) Fatalln(args ...interface{}) {
|
||||
lh.instancesMutex.Lock()
|
||||
for _, logger := range lh.instances {
|
||||
logger.Fatalln(args...)
|
||||
}
|
||||
lh.instancesMutex.Unlock()
|
||||
}
|
||||
|
||||
// Proxy for Logrus's Logger.Info() function.
|
||||
func (lh *LoggerHandler) Info(args ...interface{}) {
|
||||
lh.instancesMutex.Lock()
|
||||
for _, logger := range lh.instances {
|
||||
logger.Info(args...)
|
||||
}
|
||||
lh.instancesMutex.Unlock()
|
||||
}
|
||||
|
||||
// Proxy for Logrus's Logger.Infof() function.
|
||||
func (lh *LoggerHandler) Infof(format string, args ...interface{}) {
|
||||
lh.instancesMutex.Lock()
|
||||
for _, logger := range lh.instances {
|
||||
logger.Infof(format, args...)
|
||||
}
|
||||
lh.instancesMutex.Unlock()
|
||||
}
|
||||
|
||||
// Proxy for Logrus's Logger.Infoln() function.
|
||||
func (lh *LoggerHandler) Infoln(args ...interface{}) {
|
||||
lh.instancesMutex.Lock()
|
||||
for _, logger := range lh.instances {
|
||||
logger.Infoln(args...)
|
||||
}
|
||||
lh.instancesMutex.Unlock()
|
||||
}
|
||||
|
||||
// Proxy for Logrus's Logger.Print() function.
|
||||
func (lh *LoggerHandler) Print(args ...interface{}) {
|
||||
lh.instancesMutex.Lock()
|
||||
for _, logger := range lh.instances {
|
||||
logger.Print(args...)
|
||||
}
|
||||
lh.instancesMutex.Unlock()
|
||||
}
|
||||
|
||||
// Proxy for Logrus's Logger.Printf() function.
|
||||
func (lh *LoggerHandler) Printf(format string, args ...interface{}) {
|
||||
lh.instancesMutex.Lock()
|
||||
for _, logger := range lh.instances {
|
||||
logger.Printf(format, args...)
|
||||
}
|
||||
lh.instancesMutex.Unlock()
|
||||
}
|
||||
|
||||
// Proxy for Logrus's Logger.Println() function.
|
||||
func (lh *LoggerHandler) Println(args ...interface{}) {
|
||||
lh.instancesMutex.Lock()
|
||||
for _, logger := range lh.instances {
|
||||
logger.Println(args...)
|
||||
}
|
||||
lh.instancesMutex.Unlock()
|
||||
}
|
||||
|
||||
// Proxy for Logrus's Logger.Warn() function.
|
||||
func (lh *LoggerHandler) Warn(args ...interface{}) {
|
||||
lh.instancesMutex.Lock()
|
||||
for _, logger := range lh.instances {
|
||||
logger.Warn(args...)
|
||||
}
|
||||
lh.instancesMutex.Unlock()
|
||||
}
|
||||
|
||||
// Proxy for Logrus's Logger.Warnf() function.
|
||||
func (lh *LoggerHandler) Warnf(format string, args ...interface{}) {
|
||||
lh.instancesMutex.Lock()
|
||||
for _, logger := range lh.instances {
|
||||
logger.Warnf(format, args...)
|
||||
}
|
||||
lh.instancesMutex.Unlock()
|
||||
}
|
||||
|
||||
// Proxy for Logrus's Logger.Warnln() function.
|
||||
func (lh *LoggerHandler) Warnln(args ...interface{}) {
|
||||
lh.instancesMutex.Lock()
|
||||
for _, logger := range lh.instances {
|
||||
logger.Warnln(args...)
|
||||
}
|
||||
lh.instancesMutex.Unlock()
|
||||
}
|
44
vendor/github.com/pztrn/mogrus/mogrus.go
generated
vendored
Normal file
44
vendor/github.com/pztrn/mogrus/mogrus.go
generated
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
// Copyright (c) 2017-2018, Stanislav N. aka pztrn.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject
|
||||
// to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
||||
// OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
package mogrus
|
||||
|
||||
type MogrusLogger struct {
|
||||
// Initialized loggers.
|
||||
// Key is a name of logger.
|
||||
loggers map[string]*LoggerHandler
|
||||
}
|
||||
|
||||
// CreateLogger creates new logger handler, adds it to list of known
|
||||
// loggers and return it to caller.
|
||||
// Note that logger handler will be "just initialized", to actually
|
||||
// use it you should add output with LoggerHandler.CreateOutput().
|
||||
func (ml *MogrusLogger) CreateLogger(name string) *LoggerHandler {
|
||||
lh := &LoggerHandler{}
|
||||
lh.Initialize()
|
||||
ml.loggers[name] = lh
|
||||
|
||||
return lh
|
||||
}
|
||||
|
||||
// Initialize initializes Mogrus instance.
|
||||
func (ml *MogrusLogger) Initialize() {
|
||||
ml.loggers = make(map[string]*LoggerHandler)
|
||||
}
|
Reference in New Issue
Block a user