summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/labstack/gommon
diff options
context:
space:
mode:
authorWim <wim@42.be>2017-02-18 23:00:46 +0100
committerWim <wim@42.be>2017-02-18 23:11:48 +0100
commit930b639cc9cd2d2873302f30303378c0e53816a8 (patch)
tree8cd3f1d464fb5d4e5607fe16255c35a31a9d8b62 /vendor/github.com/labstack/gommon
parent58483ea70c2c99a352592c5e50686fb03985650e (diff)
downloadmatterbridge-msglm-930b639cc9cd2d2873302f30303378c0e53816a8.tar.gz
matterbridge-msglm-930b639cc9cd2d2873302f30303378c0e53816a8.tar.bz2
matterbridge-msglm-930b639cc9cd2d2873302f30303378c0e53816a8.zip
Update vendor
Diffstat (limited to 'vendor/github.com/labstack/gommon')
-rw-r--r--vendor/github.com/labstack/gommon/bytes/LICENSE22
-rw-r--r--vendor/github.com/labstack/gommon/bytes/bytes.go106
-rw-r--r--vendor/github.com/labstack/gommon/color/LICENSE22
-rw-r--r--vendor/github.com/labstack/gommon/color/color.go407
-rw-r--r--vendor/github.com/labstack/gommon/log/LICENSE22
-rw-r--r--vendor/github.com/labstack/gommon/log/color.go13
-rw-r--r--vendor/github.com/labstack/gommon/log/log.go405
-rw-r--r--vendor/github.com/labstack/gommon/log/white.go12
-rw-r--r--vendor/github.com/labstack/gommon/random/LICENSE22
-rw-r--r--vendor/github.com/labstack/gommon/random/random.go52
10 files changed, 1083 insertions, 0 deletions
diff --git a/vendor/github.com/labstack/gommon/bytes/LICENSE b/vendor/github.com/labstack/gommon/bytes/LICENSE
new file mode 100644
index 00000000..d2ae3edf
--- /dev/null
+++ b/vendor/github.com/labstack/gommon/bytes/LICENSE
@@ -0,0 +1,22 @@
+The MIT License (MIT)
+
+Copyright (c) 2015 labstack
+
+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.
+
diff --git a/vendor/github.com/labstack/gommon/bytes/bytes.go b/vendor/github.com/labstack/gommon/bytes/bytes.go
new file mode 100644
index 00000000..fd97e6d1
--- /dev/null
+++ b/vendor/github.com/labstack/gommon/bytes/bytes.go
@@ -0,0 +1,106 @@
+package bytes
+
+import (
+ "fmt"
+ "regexp"
+ "strconv"
+)
+
+type (
+ Bytes struct {
+ }
+)
+
+const (
+ B = 1 << (10 * iota)
+ KB
+ MB
+ GB
+ TB
+ PB
+ EB
+)
+
+var (
+ pattern = regexp.MustCompile(`(?i)^(-?\d+)([KMGTP]B?|B)$`)
+ global = New()
+)
+
+// New creates a Bytes instance.
+func New() *Bytes {
+ return &Bytes{}
+}
+
+// Format formats bytes integer to human readable string.
+// For example, 31323 bytes will return 30.59KB.
+func (*Bytes) Format(b int64) string {
+ multiple := ""
+ value := float64(b)
+
+ switch {
+ case b < KB:
+ return strconv.FormatInt(b, 10) + "B"
+ case b < MB:
+ value /= KB
+ multiple = "KB"
+ case b < MB:
+ value /= KB
+ multiple = "KB"
+ case b < GB:
+ value /= MB
+ multiple = "MB"
+ case b < TB:
+ value /= GB
+ multiple = "GB"
+ case b < PB:
+ value /= TB
+ multiple = "TB"
+ case b < EB:
+ value /= PB
+ multiple = "PB"
+ }
+
+ return fmt.Sprintf("%.02f%s", value, multiple)
+}
+
+// Parse parses human readable bytes string to bytes integer.
+// For example, 6GB (6G is also valid) will return 6442450944.
+func (*Bytes) Parse(value string) (i int64, err error) {
+ parts := pattern.FindStringSubmatch(value)
+ if len(parts) < 3 {
+ return 0, fmt.Errorf("error parsing value=%s", value)
+ }
+ bytesString := parts[1]
+ multiple := parts[2]
+ bytes, err := strconv.ParseInt(bytesString, 10, 64)
+ if err != nil {
+ return
+ }
+
+ switch multiple {
+ case "B":
+ return bytes * B, nil
+ case "K", "KB":
+ return bytes * KB, nil
+ case "M", "MB":
+ return bytes * MB, nil
+ case "G", "GB":
+ return bytes * GB, nil
+ case "T", "TB":
+ return bytes * TB, nil
+ case "P", "PB":
+ return bytes * PB, nil
+ }
+
+ return
+}
+
+// Format wraps global Bytes's Format function.
+func Format(b int64) string {
+ return global.Format(b)
+}
+
+// Parse wraps global Bytes's Parse function.
+func Parse(val string) (int64, error) {
+ return global.Parse(val)
+}
diff --git a/vendor/github.com/labstack/gommon/color/LICENSE b/vendor/github.com/labstack/gommon/color/LICENSE
new file mode 100644
index 00000000..d2ae3edf
--- /dev/null
+++ b/vendor/github.com/labstack/gommon/color/LICENSE
@@ -0,0 +1,22 @@
+The MIT License (MIT)
+
+Copyright (c) 2015 labstack
+
+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.
+
diff --git a/vendor/github.com/labstack/gommon/color/color.go b/vendor/github.com/labstack/gommon/color/color.go
new file mode 100644
index 00000000..4131dcf3
--- /dev/null
+++ b/vendor/github.com/labstack/gommon/color/color.go
@@ -0,0 +1,407 @@
+package color
+
+import (
+ "bytes"
+ "fmt"
+ "io"
+ "os"
+
+ "github.com/mattn/go-colorable"
+ "github.com/mattn/go-isatty"
+)
+
+type (
+ inner func(interface{}, []string, *Color) string
+)
+
+// Color styles
+const (
+ // Blk Black text style
+ Blk = "30"
+ // Rd red text style
+ Rd = "31"
+ // Grn green text style
+ Grn = "32"
+ // Yel yellow text style
+ Yel = "33"
+ // Blu blue text style
+ Blu = "34"
+ // Mgn magenta text style
+ Mgn = "35"
+ // Cyn cyan text style
+ Cyn = "36"
+ // Wht white text style
+ Wht = "37"
+ // Gry grey text style
+ Gry = "90"
+
+ // BlkBg black background style
+ BlkBg = "40"
+ // RdBg red background style
+ RdBg = "41"
+ // GrnBg green background style
+ GrnBg = "42"
+ // YelBg yellow background style
+ YelBg = "43"
+ // BluBg blue background style
+ BluBg = "44"
+ // MgnBg magenta background style
+ MgnBg = "45"
+ // CynBg cyan background style
+ CynBg = "46"
+ // WhtBg white background style
+ WhtBg = "47"
+
+ // R reset emphasis style
+ R = "0"
+ // B bold emphasis style
+ B = "1"
+ // D dim emphasis style
+ D = "2"
+ // I italic emphasis style
+ I = "3"
+ // U underline emphasis style
+ U = "4"
+ // In inverse emphasis style
+ In = "7"
+ // H hidden emphasis style
+ H = "8"
+ // S strikeout emphasis style
+ S = "9"
+)
+
+var (
+ black = outer(Blk)
+ red = outer(Rd)
+ green = outer(Grn)
+ yellow = outer(Yel)
+ blue = outer(Blu)
+ magenta = outer(Mgn)
+ cyan = outer(Cyn)
+ white = outer(Wht)
+ grey = outer(Gry)
+
+ blackBg = outer(BlkBg)
+ redBg = outer(RdBg)
+ greenBg = outer(GrnBg)
+ yellowBg = outer(YelBg)
+ blueBg = outer(BluBg)
+ magentaBg = outer(MgnBg)
+ cyanBg = outer(CynBg)
+ whiteBg = outer(WhtBg)
+
+ reset = outer(R)
+ bold = outer(B)
+ dim = outer(D)
+ italic = outer(I)
+ underline = outer(U)
+ inverse = outer(In)
+ hidden = outer(H)
+ strikeout = outer(S)
+
+ global = New()
+)
+
+func outer(n string) inner {
+ return func(msg interface{}, styles []string, c *Color) string {
+ // TODO: Drop fmt to boost performance?
+ if c.disabled {
+ return fmt.Sprintf("%v", msg)
+ }
+
+ b := new(bytes.Buffer)
+ b.WriteString("\x1b[")
+ b.WriteString(n)
+ for _, s := range styles {
+ b.WriteString(";")
+ b.WriteString(s)
+ }
+ b.WriteString("m")
+ return fmt.Sprintf("%s%v\x1b[0m", b.String(), msg)
+ }
+}
+
+type (
+ Color struct {
+ output io.Writer
+ disabled bool
+ }
+)
+
+// New creates a Color instance.
+func New() (c *Color) {
+ c = new(Color)
+ c.SetOutput(colorable.NewColorableStdout())
+ return
+}
+
+// Output returns the output.
+func (c *Color) Output() io.Writer {
+ return c.output
+}
+
+// SetOutput sets the output.
+func (c *Color) SetOutput(w io.Writer) {
+ c.output = w
+ if w, ok := w.(*os.File); !ok || !isatty.IsTerminal(w.Fd()) {
+ c.disabled = true
+ }
+}
+
+// Disable disables the colors and styles.
+func (c *Color) Disable() {
+ c.disabled = true
+}
+
+// Enable enables the colors and styles.
+func (c *Color) Enable() {
+ c.disabled = false
+}
+
+// Print is analogous to `fmt.Print` with termial detection.
+func (c *Color) Print(args ...interface{}) {
+ fmt.Fprint(c.output, args...)
+}
+
+// Println is analogous to `fmt.Println` with termial detection.
+func (c *Color) Println(args ...interface{}) {
+ fmt.Fprintln(c.output, args...)
+}
+
+// Printf is analogous to `fmt.Printf` with termial detection.
+func (c *Color) Printf(format string, args ...interface{}) {
+ fmt.Fprintf(c.output, format, args...)
+}
+
+func (c *Color) Black(msg interface{}, styles ...string) string {
+ return black(msg, styles, c)
+}
+
+func (c *Color) Red(msg interface{}, styles ...string) string {
+ return red(msg, styles, c)
+}
+
+func (c *Color) Green(msg interface{}, styles ...string) string {
+ return green(msg, styles, c)
+}
+
+func (c *Color) Yellow(msg interface{}, styles ...string) string {
+ return yellow(msg, styles, c)
+}
+
+func (c *Color) Blue(msg interface{}, styles ...string) string {
+ return blue(msg, styles, c)
+}
+
+func (c *Color) Magenta(msg interface{}, styles ...string) string {
+ return magenta(msg, styles, c)
+}
+
+func (c *Color) Cyan(msg interface{}, styles ...string) string {
+ return cyan(msg, styles, c)
+}
+
+func (c *Color) White(msg interface{}, styles ...string) string {
+ return white(msg, styles, c)
+}
+
+func (c *Color) Grey(msg interface{}, styles ...string) string {
+ return grey(msg, styles, c)
+}
+
+func (c *Color) BlackBg(msg interface{}, styles ...string) string {
+ return blackBg(msg, styles, c)
+}
+
+func (c *Color) RedBg(msg interface{}, styles ...string) string {
+ return redBg(msg, styles, c)
+}
+
+func (c *Color) GreenBg(msg interface{}, styles ...string) string {
+ return greenBg(msg, styles, c)
+}
+
+func (c *Color) YellowBg(msg interface{}, styles ...string) string {
+ return yellowBg(msg, styles, c)
+}
+
+func (c *Color) BlueBg(msg interface{}, styles ...string) string {
+ return blueBg(msg, styles, c)
+}
+
+func (c *Color) MagentaBg(msg interface{}, styles ...string) string {
+ return magentaBg(msg, styles, c)
+}
+
+func (c *Color) CyanBg(msg interface{}, styles ...string) string {
+ return cyanBg(msg, styles, c)
+}
+
+func (c *Color) WhiteBg(msg interface{}, styles ...string) string {
+ return whiteBg(msg, styles, c)
+}
+
+func (c *Color) Reset(msg interface{}, styles ...string) string {
+ return reset(msg, styles, c)
+}
+
+func (c *Color) Bold(msg interface{}, styles ...string) string {
+ return bold(msg, styles, c)
+}
+
+func (c *Color) Dim(msg interface{}, styles ...string) string {
+ return dim(msg, styles, c)
+}
+
+func (c *Color) Italic(msg interface{}, styles ...string) string {
+ return italic(msg, styles, c)
+}
+
+func (c *Color) Underline(msg interface{}, styles ...string) string {
+ return underline(msg, styles, c)
+}
+
+func (c *Color) Inverse(msg interface{}, styles ...string) string {
+ return inverse(msg, styles, c)
+}
+
+func (c *Color) Hidden(msg interface{}, styles ...string) string {
+ return hidden(msg, styles, c)
+}
+
+func (c *Color) Strikeout(msg interface{}, styles ...string) string {
+ return strikeout(msg, styles, c)
+}
+
+// Output returns the output.
+func Output() io.Writer {
+ return global.output
+}
+
+// SetOutput sets the output.
+func SetOutput(w io.Writer) {
+ global.SetOutput(w)
+}
+
+func Disable() {
+ global.Disable()
+}
+
+func Enable() {
+ global.Enable()
+}
+
+// Print is analogous to `fmt.Print` with termial detection.
+func Print(args ...interface{}) {
+ global.Print(args...)
+}
+
+// Println is analogous to `fmt.Println` with termial detection.
+func Println(args ...interface{}) {
+ global.Println(args...)
+}
+
+// Printf is analogous to `fmt.Printf` with termial detection.
+func Printf(format string, args ...interface{}) {
+ global.Printf(format, args...)
+}
+
+func Black(msg interface{}, styles ...string) string {
+ return global.Black(msg, styles...)
+}
+
+func Red(msg interface{}, styles ...string) string {
+ return global.Red(msg, styles...)
+}
+
+func Green(msg interface{}, styles ...string) string {
+ return global.Green(msg, styles...)
+}
+
+func Yellow(msg interface{}, styles ...string) string {
+ return global.Yellow(msg, styles...)
+}
+
+func Blue(msg interface{}, styles ...string) string {
+ return global.Blue(msg, styles...)
+}
+
+func Magenta(msg interface{}, styles ...string) string {
+ return global.Magenta(msg, styles...)
+}
+
+func Cyan(msg interface{}, styles ...string) string {
+ return global.Cyan(msg, styles...)
+}
+
+func White(msg interface{}, styles ...string) string {
+ return global.White(msg, styles...)
+}
+
+func Grey(msg interface{}, styles ...string) string {
+ return global.Grey(msg, styles...)
+}
+
+func BlackBg(msg interface{}, styles ...string) string {
+ return global.BlackBg(msg, styles...)
+}
+
+func RedBg(msg interface{}, styles ...string) string {
+ return global.RedBg(msg, styles...)
+}
+
+func GreenBg(msg interface{}, styles ...string) string {
+ return global.GreenBg(msg, styles...)
+}
+
+func YellowBg(msg interface{}, styles ...string) string {
+ return global.YellowBg(msg, styles...)
+}
+
+func BlueBg(msg interface{}, styles ...string) string {
+ return global.BlueBg(msg, styles...)
+}
+
+func MagentaBg(msg interface{}, styles ...string) string {
+ return global.MagentaBg(msg, styles...)
+}
+
+func CyanBg(msg interface{}, styles ...string) string {
+ return global.CyanBg(msg, styles...)
+}
+
+func WhiteBg(msg interface{}, styles ...string) string {
+ return global.WhiteBg(msg, styles...)
+}
+
+func Reset(msg interface{}, styles ...string) string {
+ return global.Reset(msg, styles...)
+}
+
+func Bold(msg interface{}, styles ...string) string {
+ return global.Bold(msg, styles...)
+}
+
+func Dim(msg interface{}, styles ...string) string {
+ return global.Dim(msg, styles...)
+}
+
+func Italic(msg interface{}, styles ...string) string {
+ return global.Italic(msg, styles...)
+}
+
+func Underline(msg interface{}, styles ...string) string {
+ return global.Underline(msg, styles...)
+}
+
+func Inverse(msg interface{}, styles ...string) string {
+ return global.Inverse(msg, styles...)
+}
+
+func Hidden(msg interface{}, styles ...string) string {
+ return global.Hidden(msg, styles...)
+}
+
+func Strikeout(msg interface{}, styles ...string) string {
+ return global.Strikeout(msg, styles...)
+}
diff --git a/vendor/github.com/labstack/gommon/log/LICENSE b/vendor/github.com/labstack/gommon/log/LICENSE
new file mode 100644
index 00000000..d2ae3edf
--- /dev/null
+++ b/vendor/github.com/labstack/gommon/log/LICENSE
@@ -0,0 +1,22 @@
+The MIT License (MIT)
+
+Copyright (c) 2015 labstack
+
+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.
+
diff --git a/vendor/github.com/labstack/gommon/log/color.go b/vendor/github.com/labstack/gommon/log/color.go
new file mode 100644
index 00000000..7351b39c
--- /dev/null
+++ b/vendor/github.com/labstack/gommon/log/color.go
@@ -0,0 +1,13 @@
+// +build !appengine
+
+package log
+
+import (
+ "io"
+
+ "github.com/mattn/go-colorable"
+)
+
+func output() io.Writer {
+ return colorable.NewColorableStdout()
+}
diff --git a/vendor/github.com/labstack/gommon/log/log.go b/vendor/github.com/labstack/gommon/log/log.go
new file mode 100644
index 00000000..1ac6c00c
--- /dev/null
+++ b/vendor/github.com/labstack/gommon/log/log.go
@@ -0,0 +1,405 @@
+package log
+
+import (
+ "bytes"
+ "encoding/json"
+ "fmt"
+ "io"
+ "os"
+ "path"
+ "runtime"
+ "sync"
+ "time"
+
+ "strconv"
+
+ "github.com/mattn/go-isatty"
+ "github.com/valyala/fasttemplate"
+
+ "github.com/labstack/gommon/color"
+)
+
+type (
+ Logger struct {
+ prefix string
+ level Lvl
+ output io.Writer
+ template *fasttemplate.Template
+ levels []string
+ color *color.Color
+ bufferPool sync.Pool
+ mutex sync.Mutex
+ }
+
+ Lvl uint8
+
+ JSON map[string]interface{}
+)
+
+const (
+ DEBUG Lvl = iota + 1
+ INFO
+ WARN
+ ERROR
+ OFF
+)
+
+var (
+ global = New("-")
+ defaultHeader = `{"time":"${time_rfc3339_nano}","level":"${level}","prefix":"${prefix}",` +
+ `"file":"${short_file}","line":"${line}"}`
+)
+
+func New(prefix string) (l *Logger) {
+ l = &Logger{
+ level: INFO,
+ prefix: prefix,
+ template: l.newTemplate(defaultHeader),
+ color: color.New(),
+ bufferPool: sync.Pool{
+ New: func() interface{} {
+ return bytes.NewBuffer(make([]byte, 256))
+ },
+ },
+ }
+ l.initLevels()
+ l.SetOutput(output())
+ return
+}
+
+func (l *Logger) initLevels() {
+ l.levels = []string{
+ "-",
+ l.color.Blue("DEBUG"),
+ l.color.Green("INFO"),
+ l.color.Yellow("WARN"),
+ l.color.Red("ERROR"),
+ }
+}
+
+func (l *Logger) newTemplate(format string) *fasttemplate.Template {
+ return fasttemplate.New(format, "${", "}")
+}
+
+func (l *Logger) DisableColor() {
+ l.color.Disable()
+ l.initLevels()
+}
+
+func (l *Logger) EnableColor() {
+ l.color.Enable()
+ l.initLevels()
+}
+
+func (l *Logger) Prefix() string {
+ return l.prefix
+}
+
+func (l *Logger) SetPrefix(p string) {
+ l.prefix = p
+}
+
+func (l *Logger) Level() Lvl {
+ return l.level
+}
+
+func (l *Logger) SetLevel(v Lvl) {
+ l.level = v
+}
+
+func (l *Logger) Output() io.Writer {
+ return l.output
+}
+
+func (l *Logger) SetOutput(w io.Writer) {
+ l.output = w
+ if w, ok := w.(*os.File); !ok || !isatty.IsTerminal(w.Fd()) {
+ l.DisableColor()
+ }
+}
+
+func (l *Logger) Color() *color.Color {
+ return l.color
+}
+
+func (l *Logger) SetHeader(h string) {
+ l.template = l.newTemplate(h)
+}
+
+func (l *Logger) Print(i ...interface{}) {
+ l.log(0, "", i...)
+ // fmt.Fprintln(l.output, i...)
+}
+
+func (l *Logger) Printf(format string, args ...interface{}) {
+ l.log(0, format, args...)
+}
+
+func (l *Logger) Printj(j JSON) {
+ l.log(0, "json", j)
+}
+
+func (l *Logger) Debug(i ...interface{}) {
+ l.log(DEBUG, "", i...)
+}
+
+func (l *Logger) Debugf(format string, args ...interface{}) {
+ l.log(DEBUG, format, args...)
+}
+
+func (l *Logger) Debugj(j JSON) {
+ l.log(DEBUG, "json", j)
+}
+
+func (l *Logger) Info(i ...interface{}) {
+ l.log(INFO, "", i...)
+}
+
+func (l *Logger) Infof(format string, args ...interface{}) {
+ l.log(INFO, format, args...)
+}
+
+func (l *Logger) Infoj(j JSON) {
+ l.log(INFO, "json", j)
+}
+
+func (l *Logger) Warn(i ...interface{}) {
+ l.log(WARN, "", i...)
+}
+
+func (l *Logger) Warnf(format string, args ...interface{}) {
+ l.log(WARN, format, args...)
+}
+
+func (l *Logger) Warnj(j JSON) {
+ l.log(WARN, "json", j)
+}
+
+func (l *Logger) Error(i ...interface{}) {
+ l.log(ERROR, "", i...)
+}
+
+func (l *Logger) Errorf(format string, args ...interface{}) {
+ l.log(ERROR, format, args...)
+}
+
+func (l *Logger) Errorj(j JSON) {
+ l.log(ERROR, "json", j)
+}
+
+func (l *Logger) Fatal(i ...interface{}) {
+ l.Print(i...)
+ os.Exit(1)
+}
+
+func (l *Logger) Fatalf(format string, args ...interface{}) {
+ l.Printf(format, args...)
+ os.Exit(1)
+}
+
+func (l *Logger) Fatalj(j JSON) {
+ l.Printj(j)
+ os.Exit(1)
+}
+
+func (l *Logger) Panic(i ...interface{}) {
+ l.Print(i...)
+ panic(fmt.Sprint(i...))
+}
+
+func (l *Logger) Panicf(format string, args ...interface{}) {
+ l.Printf(format, args...)
+ panic(fmt.Sprintf(format, args))
+}
+
+func (l *Logger) Panicj(j JSON) {
+ l.Printj(j)
+ panic(j)
+}
+
+func DisableColor() {
+ global.DisableColor()
+}
+
+func EnableColor() {
+ global.EnableColor()
+}
+
+func Prefix() string {
+ return global.Prefix()
+}
+
+func SetPrefix(p string) {
+ global.SetPrefix(p)
+}
+
+func Level() Lvl {
+ return global.Level()
+}
+
+func SetLevel(v Lvl) {
+ global.SetLevel(v)
+}
+
+func Output() io.Writer {
+ return global.Output()
+}
+
+func SetOutput(w io.Writer) {
+ global.SetOutput(w)
+}
+
+func SetHeader(h string) {
+ global.SetHeader(h)
+}
+
+func Print(i ...interface{}) {
+ global.Print(i...)
+}
+
+func Printf(format string, args ...interface{}) {
+ global.Printf(format, args...)
+}
+
+func Printj(j JSON) {
+ global.Printj(j)
+}
+
+func Debug(i ...interface{}) {
+ global.Debug(i...)
+}
+
+func Debugf(format string, args ...interface{}) {
+ global.Debugf(format, args...)
+}
+
+func Debugj(j JSON) {
+ global.Debugj(j)
+}
+
+func Info(i ...interface{}) {
+ global.Info(i...)
+}
+
+func Infof(format string, args ...interface{}) {
+ global.Infof(format, args...)
+}
+
+func Infoj(j JSON) {
+ global.Infoj(j)
+}
+
+func Warn(i ...interface{}) {
+ global.Warn(i...)
+}
+
+func Warnf(format string, args ...interface{}) {
+ global.Warnf(format, args...)
+}
+
+func Warnj(j JSON) {
+ global.Warnj(j)
+}
+
+func Error(i ...interface{}) {
+ global.Error(i...)
+}
+
+func Errorf(format string, args ...interface{}) {
+ global.Errorf(format, args...)
+}
+
+func Errorj(j JSON) {
+ global.Errorj(j)
+}
+
+func Fatal(i ...interface{}) {
+ global.Fatal(i...)
+}
+
+func Fatalf(format string, args ...interface{}) {
+ global.Fatalf(format, args...)
+}
+
+func Fatalj(j JSON) {
+ global.Fatalj(j)
+}
+
+func Panic(i ...interface{}) {
+ global.Panic(i...)
+}
+
+func Panicf(format string, args ...interface{}) {
+ global.Panicf(format, args...)
+}
+
+func Panicj(j JSON) {
+ global.Panicj(j)
+}
+
+func (l *Logger) log(v Lvl, format string, args ...interface{}) {
+ l.mutex.Lock()
+ defer l.mutex.Unlock()
+ buf := l.bufferPool.Get().(*bytes.Buffer)
+ buf.Reset()
+ defer l.bufferPool.Put(buf)
+ _, file, line, _ := runtime.Caller(3)
+
+ if v >= l.level || v == 0 {
+ message := ""
+ if format == "" {
+ message = fmt.Sprint(args...)
+ } else if format == "json" {
+ b, err := json.Marshal(args[0])
+ if err != nil {
+ panic(err)
+ }
+ message = string(b)
+ } else {
+ message = fmt.Sprintf(format, args...)
+ }
+
+ _, err := l.template.ExecuteFunc(buf, func(w io.Writer, tag string) (int, error) {
+ switch tag {
+ case "time_rfc3339":
+ return w.Write([]byte(time.Now().Format(time.RFC3339)))
+ case "time_rfc3339_nano":
+ return w.Write([]byte(time.Now().Format(time.RFC3339Nano)))
+ case "level":
+ return w.Write([]byte(l.levels[v]))
+ case "prefix":
+ return w.Write([]byte(l.prefix))
+ case "long_file":
+ return w.Write([]byte(file))
+ case "short_file":
+ return w.Write([]byte(path.Base(file)))
+ case "line":
+ return w.Write([]byte(strconv.Itoa(line)))
+ }
+ return 0, nil
+ })
+
+ if err == nil {
+ s := buf.String()
+ i := buf.Len() - 1
+ if s[i] == '}' {
+ // JSON header
+ buf.Truncate(i)
+ buf.WriteByte(',')
+ if format == "json" {
+ buf.WriteString(message[1:])
+ } else {
+ buf.WriteString(`"message":`)
+ buf.WriteString(strconv.Quote(message))
+ buf.WriteString(`}`)
+ }
+ } else {
+ // Text header
+ buf.WriteByte(' ')
+ buf.WriteString(message)
+ }
+ buf.WriteByte('\n')
+ l.output.Write(buf.Bytes())
+ }
+ }
+}
diff --git a/vendor/github.com/labstack/gommon/log/white.go b/vendor/github.com/labstack/gommon/log/white.go
new file mode 100644
index 00000000..746cc562
--- /dev/null
+++ b/vendor/github.com/labstack/gommon/log/white.go
@@ -0,0 +1,12 @@
+// +build appengine
+
+package log
+
+import (
+ "io"
+ "os"
+)
+
+func output() io.Writer {
+ return os.Stdout
+}
diff --git a/vendor/github.com/labstack/gommon/random/LICENSE b/vendor/github.com/labstack/gommon/random/LICENSE
new file mode 100644
index 00000000..d2ae3edf
--- /dev/null
+++ b/vendor/github.com/labstack/gommon/random/LICENSE
@@ -0,0 +1,22 @@
+The MIT License (MIT)
+
+Copyright (c) 2015 labstack
+
+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.
+
diff --git a/vendor/github.com/labstack/gommon/random/random.go b/vendor/github.com/labstack/gommon/random/random.go
new file mode 100644
index 00000000..b76bd9b3
--- /dev/null
+++ b/vendor/github.com/labstack/gommon/random/random.go
@@ -0,0 +1,52 @@
+package random
+
+import (
+ "math/rand"
+ "time"
+)
+
+type (
+ Random struct {
+ charset Charset
+ }
+
+ Charset string
+)
+
+const (
+ Alphanumeric Charset = Alphabetic + Numeric
+ Alphabetic Charset = "abcdefghijklmnopqrstuvwxyz" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ Numeric Charset = "0123456789"
+ Hex Charset = Numeric + "abcdef"
+)
+
+var (
+ global = New()
+)
+
+func New() *Random {
+ rand.Seed(time.Now().UnixNano())
+ return &Random{
+ charset: Alphanumeric,
+ }
+}
+
+func (r *Random) SetCharset(c Charset) {
+ r.charset = c
+}
+
+func (r *Random) String(length uint8) string {
+ b := make([]byte, length)
+ for i := range b {
+ b[i] = r.charset[rand.Int63()%int64(len(r.charset))]
+ }
+ return string(b)
+}
+
+func SetCharset(c Charset) {
+ global.SetCharset(c)
+}
+
+func String(length uint8) string {
+ return global.String(length)
+}