summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/labstack/gommon
diff options
context:
space:
mode:
authorWim <wim@42.be>2019-01-31 17:06:36 +0100
committerWim <wim@42.be>2019-01-31 17:06:36 +0100
commitc81c0dd22a7779148c4890cfd4bbf490054f06f1 (patch)
tree06ce6fcdc8f3a2278a2f3050ba42088dd2e64485 /vendor/github.com/labstack/gommon
parentf8a1ab4622a5b833282e9ee42f382451d17c1a06 (diff)
downloadmatterbridge-msglm-c81c0dd22a7779148c4890cfd4bbf490054f06f1.tar.gz
matterbridge-msglm-c81c0dd22a7779148c4890cfd4bbf490054f06f1.tar.bz2
matterbridge-msglm-c81c0dd22a7779148c4890cfd4bbf490054f06f1.zip
Update vendor, move to labstack/echo/v4 Fixes #698
Diffstat (limited to 'vendor/github.com/labstack/gommon')
-rw-r--r--vendor/github.com/labstack/gommon/LICENSE2
-rw-r--r--vendor/github.com/labstack/gommon/bytes/bytes.go68
-rw-r--r--vendor/github.com/labstack/gommon/log/log.go30
-rw-r--r--vendor/github.com/labstack/gommon/random/random.go14
4 files changed, 63 insertions, 51 deletions
diff --git a/vendor/github.com/labstack/gommon/LICENSE b/vendor/github.com/labstack/gommon/LICENSE
index d2ae3edf..fc718faf 100644
--- a/vendor/github.com/labstack/gommon/LICENSE
+++ b/vendor/github.com/labstack/gommon/LICENSE
@@ -1,6 +1,6 @@
The MIT License (MIT)
-Copyright (c) 2015 labstack
+Copyright (c) 2018 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
diff --git a/vendor/github.com/labstack/gommon/bytes/bytes.go b/vendor/github.com/labstack/gommon/bytes/bytes.go
index fd97e6d1..746436cb 100644
--- a/vendor/github.com/labstack/gommon/bytes/bytes.go
+++ b/vendor/github.com/labstack/gommon/bytes/bytes.go
@@ -7,12 +7,12 @@ import (
)
type (
- Bytes struct {
- }
+ // Bytes struct
+ Bytes struct{}
)
const (
- B = 1 << (10 * iota)
+ _ = 1.0 << (10 * iota) // ignore first value by assigning to blank identifier
KB
MB
GB
@@ -22,7 +22,7 @@ const (
)
var (
- pattern = regexp.MustCompile(`(?i)^(-?\d+)([KMGTP]B?|B)$`)
+ pattern = regexp.MustCompile(`(?i)^(-?\d+(?:\.\d+)?)([KMGTPE]B?|B?)$`)
global = New()
)
@@ -38,29 +38,31 @@ func (*Bytes) Format(b int64) string {
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:
+ case b >= EB:
+ value /= EB
+ multiple = "EB"
+ case b >= PB:
value /= PB
multiple = "PB"
+ case b >= TB:
+ value /= TB
+ multiple = "TB"
+ case b >= GB:
+ value /= GB
+ multiple = "GB"
+ case b >= MB:
+ value /= MB
+ multiple = "MB"
+ case b >= KB:
+ value /= KB
+ multiple = "KB"
+ case b == 0:
+ return "0"
+ default:
+ return strconv.FormatInt(b, 10) + "B"
}
- return fmt.Sprintf("%.02f%s", value, multiple)
+ return fmt.Sprintf("%.2f%s", value, multiple)
}
// Parse parses human readable bytes string to bytes integer.
@@ -72,27 +74,27 @@ func (*Bytes) Parse(value string) (i int64, err error) {
}
bytesString := parts[1]
multiple := parts[2]
- bytes, err := strconv.ParseInt(bytesString, 10, 64)
+ bytes, err := strconv.ParseFloat(bytesString, 64)
if err != nil {
return
}
switch multiple {
- case "B":
- return bytes * B, nil
+ default:
+ return int64(bytes), nil
case "K", "KB":
- return bytes * KB, nil
+ return int64(bytes * KB), nil
case "M", "MB":
- return bytes * MB, nil
+ return int64(bytes * MB), nil
case "G", "GB":
- return bytes * GB, nil
+ return int64(bytes * GB), nil
case "T", "TB":
- return bytes * TB, nil
+ return int64(bytes * TB), nil
case "P", "PB":
- return bytes * PB, nil
+ return int64(bytes * PB), nil
+ case "E", "EB":
+ return int64(bytes * EB), nil
}
-
- return
}
// Format wraps global Bytes's Format function.
diff --git a/vendor/github.com/labstack/gommon/log/log.go b/vendor/github.com/labstack/gommon/log/log.go
index 1ac6c00c..132411db 100644
--- a/vendor/github.com/labstack/gommon/log/log.go
+++ b/vendor/github.com/labstack/gommon/log/log.go
@@ -8,11 +8,10 @@ import (
"os"
"path"
"runtime"
+ "strconv"
"sync"
"time"
- "strconv"
-
"github.com/mattn/go-isatty"
"github.com/valyala/fasttemplate"
@@ -23,6 +22,7 @@ type (
Logger struct {
prefix string
level Lvl
+ skip int
output io.Writer
template *fasttemplate.Template
levels []string
@@ -42,6 +42,8 @@ const (
WARN
ERROR
OFF
+ panicLevel
+ fatalLevel
)
var (
@@ -50,9 +52,14 @@ var (
`"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(),
@@ -74,6 +81,9 @@ func (l *Logger) initLevels() {
l.color.Green("INFO"),
l.color.Yellow("WARN"),
l.color.Red("ERROR"),
+ "",
+ l.color.Yellow("PANIC", color.U),
+ l.color.Red("FATAL", color.U),
}
}
@@ -188,32 +198,32 @@ func (l *Logger) Errorj(j JSON) {
}
func (l *Logger) Fatal(i ...interface{}) {
- l.Print(i...)
+ l.log(fatalLevel, "", i...)
os.Exit(1)
}
func (l *Logger) Fatalf(format string, args ...interface{}) {
- l.Printf(format, args...)
+ l.log(fatalLevel, format, args...)
os.Exit(1)
}
func (l *Logger) Fatalj(j JSON) {
- l.Printj(j)
+ l.log(fatalLevel, "json", j)
os.Exit(1)
}
func (l *Logger) Panic(i ...interface{}) {
- l.Print(i...)
+ l.log(panicLevel, "", i...)
panic(fmt.Sprint(i...))
}
func (l *Logger) Panicf(format string, args ...interface{}) {
- l.Printf(format, args...)
- panic(fmt.Sprintf(format, args))
+ l.log(panicLevel, format, args...)
+ panic(fmt.Sprintf(format, args...))
}
func (l *Logger) Panicj(j JSON) {
- l.Printj(j)
+ l.log(panicLevel, "json", j)
panic(j)
}
@@ -343,7 +353,7 @@ func (l *Logger) log(v Lvl, format string, args ...interface{}) {
buf := l.bufferPool.Get().(*bytes.Buffer)
buf.Reset()
defer l.bufferPool.Put(buf)
- _, file, line, _ := runtime.Caller(3)
+ _, file, line, _ := runtime.Caller(l.skip)
if v >= l.level || v == 0 {
message := ""
diff --git a/vendor/github.com/labstack/gommon/random/random.go b/vendor/github.com/labstack/gommon/random/random.go
index b1ae864a..482d0524 100644
--- a/vendor/github.com/labstack/gommon/random/random.go
+++ b/vendor/github.com/labstack/gommon/random/random.go
@@ -13,13 +13,13 @@ type (
// Charsets
const (
- Uppercase string = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- Lowercase = "abcdefghijklmnopqrstuvwxyz"
- Alphabetic = Uppercase + Lowercase
- Numeric = "0123456789"
- Alphanumeric = Alphabetic + Numeric
- Symbols = "`" + `~!@#$%^&*()-_+={}[]|\;:"<>,./?`
- Hex = Numeric + "abcdef"
+ Uppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ Lowercase = "abcdefghijklmnopqrstuvwxyz"
+ Alphabetic = Uppercase + Lowercase
+ Numeric = "0123456789"
+ Alphanumeric = Alphabetic + Numeric
+ Symbols = "`" + `~!@#$%^&*()-_+={}[]|\;:"<>,./?`
+ Hex = Numeric + "abcdef"
)
var (