aboutsummaryrefslogtreecommitdiffstats
path: root/src/dma/vendor/github.com/labstack/gommon
diff options
context:
space:
mode:
authorToshiaki Takahashi <takahashi.tsc@ncos.nec.co.jp>2018-09-06 09:04:29 +0000
committerToshiaki Takahashi <takahashi.tsc@ncos.nec.co.jp>2018-09-07 06:03:01 +0000
commitd61931341176dad9ccff7c967a10d88fe54218fa (patch)
tree526457882d4abe0c38d2242d6daa311bf8ef51cf /src/dma/vendor/github.com/labstack/gommon
parent73abc060f31a6bf866fa1dad0a1a6efdfd94d775 (diff)
src: Add DMA localagent
Change-Id: Ibcee814fbc9a904448eeb368a1a26bbb69cf54aa Signed-off-by: Toshiaki Takahashi <takahashi.tsc@ncos.nec.co.jp>
Diffstat (limited to 'src/dma/vendor/github.com/labstack/gommon')
-rw-r--r--src/dma/vendor/github.com/labstack/gommon/LICENSE22
-rw-r--r--src/dma/vendor/github.com/labstack/gommon/color/README.md86
-rw-r--r--src/dma/vendor/github.com/labstack/gommon/color/color.go407
-rw-r--r--src/dma/vendor/github.com/labstack/gommon/log/README.md5
-rw-r--r--src/dma/vendor/github.com/labstack/gommon/log/color.go13
-rw-r--r--src/dma/vendor/github.com/labstack/gommon/log/log.go415
-rw-r--r--src/dma/vendor/github.com/labstack/gommon/log/white.go12
7 files changed, 960 insertions, 0 deletions
diff --git a/src/dma/vendor/github.com/labstack/gommon/LICENSE b/src/dma/vendor/github.com/labstack/gommon/LICENSE
new file mode 100644
index 00000000..d2ae3edf
--- /dev/null
+++ b/src/dma/vendor/github.com/labstack/gommon/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/src/dma/vendor/github.com/labstack/gommon/color/README.md b/src/dma/vendor/github.com/labstack/gommon/color/README.md
new file mode 100644
index 00000000..297c3518
--- /dev/null
+++ b/src/dma/vendor/github.com/labstack/gommon/color/README.md
@@ -0,0 +1,86 @@
+# Color
+
+Style terminal text.
+
+## Installation
+
+```sh
+go get github.com/labstack/gommon/color
+```
+
+## Windows?
+
+Try [cmder](http://bliker.github.io/cmder) or https://github.com/mattn/go-colorable
+
+## [Usage](https://github.com/labstack/gommon/blob/master/color/color_test.go)
+
+```sh
+import github.com/labstack/gommon/color
+```
+
+### Colored text
+
+```go
+color.Println(color.Black("black"))
+color.Println(color.Red("red"))
+color.Println(color.Green("green"))
+color.Println(color.Yellow("yellow"))
+color.Println(color.Blue("blue"))
+color.Println(color.Magenta("magenta"))
+color.Println(color.Cyan("cyan"))
+color.Println(color.White("white"))
+color.Println(color.Grey("grey"))
+```
+![Colored Text](http://i.imgur.com/8RtY1QR.png)
+
+### Colored background
+
+```go
+color.Println(color.BlackBg("black background", color.Wht))
+color.Println(color.RedBg("red background"))
+color.Println(color.GreenBg("green background"))
+color.Println(color.YellowBg("yellow background"))
+color.Println(color.BlueBg("blue background"))
+color.Println(color.MagentaBg("magenta background"))
+color.Println(color.CyanBg("cyan background"))
+color.Println(color.WhiteBg("white background"))
+```
+![Colored Background](http://i.imgur.com/SrrS6lw.png)
+
+### Emphasis
+
+```go
+color.Println(color.Bold("bold"))
+color.Println(color.Dim("dim"))
+color.Println(color.Italic("italic"))
+color.Println(color.Underline("underline"))
+color.Println(color.Inverse("inverse"))
+color.Println(color.Hidden("hidden"))
+color.Println(color.Strikeout("strikeout"))
+```
+![Emphasis](http://i.imgur.com/3RSJBbc.png)
+
+### Mix and match
+
+```go
+color.Println(color.Green("bold green with white background", color.B, color.WhtBg))
+color.Println(color.Red("underline red", color.U))
+color.Println(color.Yellow("dim yellow", color.D))
+color.Println(color.Cyan("inverse cyan", color.In))
+color.Println(color.Blue("bold underline dim blue", color.B, color.U, color.D))
+```
+![Mix and match](http://i.imgur.com/jWGq9Ca.png)
+
+### Enable/Disable the package
+
+```go
+color.Disable()
+color.Enable()
+```
+
+### New instance
+
+```go
+c := New()
+c.Green("green")
+```
diff --git a/src/dma/vendor/github.com/labstack/gommon/color/color.go b/src/dma/vendor/github.com/labstack/gommon/color/color.go
new file mode 100644
index 00000000..4131dcf3
--- /dev/null
+++ b/src/dma/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/src/dma/vendor/github.com/labstack/gommon/log/README.md b/src/dma/vendor/github.com/labstack/gommon/log/README.md
new file mode 100644
index 00000000..d5b9e9f0
--- /dev/null
+++ b/src/dma/vendor/github.com/labstack/gommon/log/README.md
@@ -0,0 +1,5 @@
+## WORK IN PROGRESS
+
+### Usage
+
+[log_test.go](log_test.go)
diff --git a/src/dma/vendor/github.com/labstack/gommon/log/color.go b/src/dma/vendor/github.com/labstack/gommon/log/color.go
new file mode 100644
index 00000000..7351b39c
--- /dev/null
+++ b/src/dma/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/src/dma/vendor/github.com/labstack/gommon/log/log.go b/src/dma/vendor/github.com/labstack/gommon/log/log.go
new file mode 100644
index 00000000..0d77a87a
--- /dev/null
+++ b/src/dma/vendor/github.com/labstack/gommon/log/log.go
@@ -0,0 +1,415 @@
+package log
+
+import (
+ "bytes"
+ "encoding/json"
+ "fmt"
+ "io"
+ "os"
+ "path"
+ "runtime"
+ "strconv"
+ "sync"
+ "time"
+
+ "github.com/mattn/go-isatty"
+ "github.com/valyala/fasttemplate"
+
+ "github.com/labstack/gommon/color"
+)
+
+type (
+ Logger struct {
+ prefix string
+ level Lvl
+ skip int
+ 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
+ panicLevel
+ fatalLevel
+)
+
+var (
+ global = New("-")
+ defaultHeader = `{"time":"${time_rfc3339_nano}","level":"${level}","prefix":"${prefix}",` +
+ `"file":"${short_file}","line":"${line}"}`
+)
+
+func init() {
+ global.skip = 3
+}
+
+func New(prefix string) (l *Logger) {
+ l = &Logger{
+ level: INFO,
+ skip: 2,
+ 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"),
+ "",
+ l.color.Yellow("PANIC", color.U),
+ l.color.Red("FATAL", color.U),
+ }
+}
+
+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.log(fatalLevel, "", i...)
+ os.Exit(1)
+}
+
+func (l *Logger) Fatalf(format string, args ...interface{}) {
+ l.log(fatalLevel, format, args...)
+ os.Exit(1)
+}
+
+func (l *Logger) Fatalj(j JSON) {
+ l.log(fatalLevel, "json", j)
+ os.Exit(1)
+}
+
+func (l *Logger) Panic(i ...interface{}) {
+ l.log(panicLevel, "", i...)
+ panic(fmt.Sprint(i...))
+}
+
+func (l *Logger) Panicf(format string, args ...interface{}) {
+ l.log(panicLevel, format, args...)
+ panic(fmt.Sprintf(format, args))
+}
+
+func (l *Logger) Panicj(j JSON) {
+ l.log(panicLevel, "json", 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(l.skip)
+
+ 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/src/dma/vendor/github.com/labstack/gommon/log/white.go b/src/dma/vendor/github.com/labstack/gommon/log/white.go
new file mode 100644
index 00000000..746cc562
--- /dev/null
+++ b/src/dma/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
+}