Release v0.1.0

This commit is contained in:
Manu Herrera
2019-10-01 12:22:30 -03:00
parent 41e6aad190
commit d301c63596
915 changed files with 378049 additions and 11 deletions

28
vendor/github.com/btcsuite/btclog/.gitignore generated vendored Normal file
View File

@@ -0,0 +1,28 @@
# Temp files
*~
# Log files
*.log
# Compiled Object files, Static and Dynamic libs (Shared Objects)
*.o
*.a
*.so
# Folders
_obj
_test
# Architecture specific extensions/prefixes
*.[568vq]
[568vq].out
*.cgo1.go
*.cgo2.c
_cgo_defun.c
_cgo_gotypes.go
_cgo_export.*
_testmain.go
*.exe

13
vendor/github.com/btcsuite/btclog/.travis.yml generated vendored Normal file
View File

@@ -0,0 +1,13 @@
language: go
go:
- 1.7.x
- 1.8.x
sudo: false
install:
- go get -d -t -v ./...
- go get -v golang.org/x/tools/cmd/cover
- go get -v github.com/bradfitz/goimports
- go get -v github.com/golang/lint/golint
script:
- export PATH=$PATH:$HOME/gopath/bin
- ./goclean.sh

15
vendor/github.com/btcsuite/btclog/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,15 @@
ISC License
Copyright (c) 2013-2014 Conformal Systems LLC.
Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

40
vendor/github.com/btcsuite/btclog/README.md generated vendored Normal file
View File

@@ -0,0 +1,40 @@
btclog
======
[![Build Status](http://img.shields.io/travis/btcsuite/btclog.svg)](https://travis-ci.org/btcsuite/btclog)
[![ISC License](http://img.shields.io/badge/license-ISC-blue.svg)](http://copyfree.org)
[![GoDoc](https://img.shields.io/badge/godoc-reference-blue.svg)](http://godoc.org/github.com/btcsuite/btclog)
Package btclog defines a logger interface and provides a default implementation
of a subsystem-aware leveled logger implementing the same interface.
## Installation
```bash
$ go get github.com/btcsuite/btclog
```
## GPG Verification Key
All official release tags are signed by Conformal so users can ensure the code
has not been tampered with and is coming from the btcsuite developers. To
verify the signature perform the following:
- Download the public key from the Conformal website at
https://opensource.conformal.com/GIT-GPG-KEY-conformal.txt
- Import the public key into your GPG keyring:
```bash
gpg --import GIT-GPG-KEY-conformal.txt
```
- Verify the release tag with the following command where `TAG_NAME` is a
placeholder for the specific tag:
```bash
git tag -v TAG_NAME
```
## License
Package btclog is licensed under the [copyfree](http://copyfree.org) ISC
License.

27
vendor/github.com/btcsuite/btclog/doc.go generated vendored Normal file
View File

@@ -0,0 +1,27 @@
// Copyright (c) 2013-2017 The btcsuite developers
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.
/*
Package btclog defines an interface and default implementation for subsystem
logging.
Log level verbosity may be modified at runtime for each individual subsystem
logger.
The default implementation in this package must be created by the Backend type.
Backends can write to any io.Writer, including multi-writers created by
io.MultiWriter. Multi-writers allow log output to be written to many writers,
including standard output and log files.
Optional logging behavior can be specified by using the LOGFLAGS environment
variable and overridden per-Backend by using the WithFlags call option. Multiple
LOGFLAGS options can be specified, separated by commas. The following options
are recognized:
longfile: Include the full filepath and line number in all log messages
shortfile: Include the filename and line number in all log messages.
Overrides longfile.
*/
package btclog

37
vendor/github.com/btcsuite/btclog/goclean.sh generated vendored Normal file
View File

@@ -0,0 +1,37 @@
#!/bin/bash
# The script does automatic checking on a Go package and its sub-packages, including:
# 1. gofmt (http://golang.org/cmd/gofmt/)
# 2. goimports (https://github.com/bradfitz/goimports)
# 3. golint (https://github.com/golang/lint)
# 4. go vet (http://golang.org/cmd/vet)
# 5. race detector (http://blog.golang.org/race-detector)
# 6. test coverage (http://blog.golang.org/cover)
set -e
# Automatic checks
test -z $(gofmt -l -w . | tee /dev/stderr)
test -z $(goimports -l -w . | tee /dev/stderr)
test -z $(golint ./... | tee /dev/stderr)
go vet ./...
env GORACE="halt_on_error=1" go test -v -race ./...
# Run test coverage on each subdirectories and merge the coverage profile.
echo "mode: count" > profile.cov
# Standard go tooling behavior is to ignore dirs with leading underscores.
for dir in $(find . -maxdepth 10 -not -path './.git*' -not -path '*/_*' -type d)
do
if ls $dir/*.go &> /dev/null; then
go test -covermode=count -coverprofile=$dir/profile.tmp $dir
if [ -f $dir/profile.tmp ]; then
cat $dir/profile.tmp | tail -n +2 >> profile.cov
rm $dir/profile.tmp
fi
fi
done
# To submit the test coverage result to coveralls.io,
# use goveralls (https://github.com/mattn/goveralls)
# goveralls -coverprofile=profile.cov -service=travis-ci

64
vendor/github.com/btcsuite/btclog/interface.go generated vendored Normal file
View File

@@ -0,0 +1,64 @@
// Copyright (c) 2013-2017 The btcsuite developers
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.
package btclog
// Logger is an interface which describes a level-based logger. A default
// implementation of Logger is implemented by this package and can be created
// by calling (*Backend).Logger.
type Logger interface {
// Tracef formats message according to format specifier and writes to
// to log with LevelTrace.
Tracef(format string, params ...interface{})
// Debugf formats message according to format specifier and writes to
// log with LevelDebug.
Debugf(format string, params ...interface{})
// Infof formats message according to format specifier and writes to
// log with LevelInfo.
Infof(format string, params ...interface{})
// Warnf formats message according to format specifier and writes to
// to log with LevelWarn.
Warnf(format string, params ...interface{})
// Errorf formats message according to format specifier and writes to
// to log with LevelError.
Errorf(format string, params ...interface{})
// Criticalf formats message according to format specifier and writes to
// log with LevelCritical.
Criticalf(format string, params ...interface{})
// Trace formats message using the default formats for its operands
// and writes to log with LevelTrace.
Trace(v ...interface{})
// Debug formats message using the default formats for its operands
// and writes to log with LevelDebug.
Debug(v ...interface{})
// Info formats message using the default formats for its operands
// and writes to log with LevelInfo.
Info(v ...interface{})
// Warn formats message using the default formats for its operands
// and writes to log with LevelWarn.
Warn(v ...interface{})
// Error formats message using the default formats for its operands
// and writes to log with LevelError.
Error(v ...interface{})
// Critical formats message using the default formats for its operands
// and writes to log with LevelCritical.
Critical(v ...interface{})
// Level returns the current logging level.
Level() Level
// SetLevel changes the logging level to the passed level.
SetLevel(level Level)
}

480
vendor/github.com/btcsuite/btclog/log.go generated vendored Normal file
View File

@@ -0,0 +1,480 @@
// Copyright (c) 2017 The btcsuite developers
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.
//
// Copyright (c) 2009 The Go Authors. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package btclog
import (
"bytes"
"fmt"
"io"
"io/ioutil"
"os"
"runtime"
"strings"
"sync"
"sync/atomic"
"time"
)
// defaultFlags specifies changes to the default logger behavior. It is set
// during package init and configured using the LOGFLAGS environment variable.
// New logger backends can override these default flags using WithFlags.
var defaultFlags uint32
// Flags to modify Backend's behavior.
const (
// Llongfile modifies the logger output to include full path and line number
// of the logging callsite, e.g. /a/b/c/main.go:123.
Llongfile uint32 = 1 << iota
// Lshortfile modifies the logger output to include filename and line number
// of the logging callsite, e.g. main.go:123. Overrides Llongfile.
Lshortfile
)
// Read logger flags from the LOGFLAGS environment variable. Multiple flags can
// be set at once, separated by commas.
func init() {
for _, f := range strings.Split(os.Getenv("LOGFLAGS"), ",") {
switch f {
case "longfile":
defaultFlags |= Llongfile
case "shortfile":
defaultFlags |= Lshortfile
}
}
}
// Level is the level at which a logger is configured. All messages sent
// to a level which is below the current level are filtered.
type Level uint32
// Level constants.
const (
LevelTrace Level = iota
LevelDebug
LevelInfo
LevelWarn
LevelError
LevelCritical
LevelOff
)
// levelStrs defines the human-readable names for each logging level.
var levelStrs = [...]string{"TRC", "DBG", "INF", "WRN", "ERR", "CRT", "OFF"}
// LevelFromString returns a level based on the input string s. If the input
// can't be interpreted as a valid log level, the info level and false is
// returned.
func LevelFromString(s string) (l Level, ok bool) {
switch strings.ToLower(s) {
case "trace", "trc":
return LevelTrace, true
case "debug", "dbg":
return LevelDebug, true
case "info", "inf":
return LevelInfo, true
case "warn", "wrn":
return LevelWarn, true
case "error", "err":
return LevelError, true
case "critical", "crt":
return LevelCritical, true
case "off":
return LevelOff, true
default:
return LevelInfo, false
}
}
// String returns the tag of the logger used in log messages, or "OFF" if
// the level will not produce any log output.
func (l Level) String() string {
if l >= LevelOff {
return "OFF"
}
return levelStrs[l]
}
// NewBackend creates a logger backend from a Writer.
func NewBackend(w io.Writer, opts ...BackendOption) *Backend {
b := &Backend{w: w, flag: defaultFlags}
for _, o := range opts {
o(b)
}
return b
}
// Backend is a logging backend. Subsystems created from the backend write to
// the backend's Writer. Backend provides atomic writes to the Writer from all
// subsystems.
type Backend struct {
w io.Writer
mu sync.Mutex // ensures atomic writes
flag uint32
}
// BackendOption is a function used to modify the behavior of a Backend.
type BackendOption func(b *Backend)
// WithFlags configures a Backend to use the specified flags rather than using
// the package's defaults as determined through the LOGFLAGS environment
// variable.
func WithFlags(flags uint32) BackendOption {
return func(b *Backend) {
b.flag = flags
}
}
// bufferPool defines a concurrent safe free list of byte slices used to provide
// temporary buffers for formatting log messages prior to outputting them.
var bufferPool = sync.Pool{
New: func() interface{} {
b := make([]byte, 0, 120)
return &b // pointer to slice to avoid boxing alloc
},
}
// buffer returns a byte slice from the free list. A new buffer is allocated if
// there are not any available on the free list. The returned byte slice should
// be returned to the fee list by using the recycleBuffer function when the
// caller is done with it.
func buffer() *[]byte {
return bufferPool.Get().(*[]byte)
}
// recycleBuffer puts the provided byte slice, which should have been obtain via
// the buffer function, back on the free list.
func recycleBuffer(b *[]byte) {
*b = (*b)[:0]
bufferPool.Put(b)
}
// From stdlib log package.
// Cheap integer to fixed-width decimal ASCII. Give a negative width to avoid
// zero-padding.
func itoa(buf *[]byte, i int, wid int) {
// Assemble decimal in reverse order.
var b [20]byte
bp := len(b) - 1
for i >= 10 || wid > 1 {
wid--
q := i / 10
b[bp] = byte('0' + i - q*10)
bp--
i = q
}
// i < 10
b[bp] = byte('0' + i)
*buf = append(*buf, b[bp:]...)
}
// Appends a header in the default format 'YYYY-MM-DD hh:mm:ss.sss [LVL] TAG: '.
// If either of the Lshortfile or Llongfile flags are specified, the file named
// and line number are included after the tag and before the final colon.
func formatHeader(buf *[]byte, t time.Time, lvl, tag string, file string, line int) {
year, month, day := t.Date()
hour, min, sec := t.Clock()
ms := t.Nanosecond() / 1e6
itoa(buf, year, 4)
*buf = append(*buf, '-')
itoa(buf, int(month), 2)
*buf = append(*buf, '-')
itoa(buf, day, 2)
*buf = append(*buf, ' ')
itoa(buf, hour, 2)
*buf = append(*buf, ':')
itoa(buf, min, 2)
*buf = append(*buf, ':')
itoa(buf, sec, 2)
*buf = append(*buf, '.')
itoa(buf, ms, 3)
*buf = append(*buf, " ["...)
*buf = append(*buf, lvl...)
*buf = append(*buf, "] "...)
*buf = append(*buf, tag...)
if file != "" {
*buf = append(*buf, ' ')
*buf = append(*buf, file...)
*buf = append(*buf, ':')
itoa(buf, line, -1)
}
*buf = append(*buf, ": "...)
}
// calldepth is the call depth of the callsite function relative to the
// caller of the subsystem logger. It is used to recover the filename and line
// number of the logging call if either the short or long file flags are
// specified.
const calldepth = 3
// callsite returns the file name and line number of the callsite to the
// subsystem logger.
func callsite(flag uint32) (string, int) {
_, file, line, ok := runtime.Caller(calldepth)
if !ok {
return "???", 0
}
if flag&Lshortfile != 0 {
short := file
for i := len(file) - 1; i > 0; i-- {
if os.IsPathSeparator(file[i]) {
short = file[i+1:]
break
}
}
file = short
}
return file, line
}
// print outputs a log message to the writer associated with the backend after
// creating a prefix for the given level and tag according to the formatHeader
// function and formatting the provided arguments using the default formatting
// rules.
func (b *Backend) print(lvl, tag string, args ...interface{}) {
t := time.Now() // get as early as possible
bytebuf := buffer()
var file string
var line int
if b.flag&(Lshortfile|Llongfile) != 0 {
file, line = callsite(b.flag)
}
formatHeader(bytebuf, t, lvl, tag, file, line)
buf := bytes.NewBuffer(*bytebuf)
fmt.Fprintln(buf, args...)
*bytebuf = buf.Bytes()
b.mu.Lock()
b.w.Write(*bytebuf)
b.mu.Unlock()
recycleBuffer(bytebuf)
}
// printf outputs a log message to the writer associated with the backend after
// creating a prefix for the given level and tag according to the formatHeader
// function and formatting the provided arguments according to the given format
// specifier.
func (b *Backend) printf(lvl, tag string, format string, args ...interface{}) {
t := time.Now() // get as early as possible
bytebuf := buffer()
var file string
var line int
if b.flag&(Lshortfile|Llongfile) != 0 {
file, line = callsite(b.flag)
}
formatHeader(bytebuf, t, lvl, tag, file, line)
buf := bytes.NewBuffer(*bytebuf)
fmt.Fprintf(buf, format, args...)
*bytebuf = append(buf.Bytes(), '\n')
b.mu.Lock()
b.w.Write(*bytebuf)
b.mu.Unlock()
recycleBuffer(bytebuf)
}
// Logger returns a new logger for a particular subsystem that writes to the
// Backend b. A tag describes the subsystem and is included in all log
// messages. The logger uses the info verbosity level by default.
func (b *Backend) Logger(subsystemTag string) Logger {
return &slog{LevelInfo, subsystemTag, b}
}
// slog is a subsystem logger for a Backend. Implements the Logger interface.
type slog struct {
lvl Level // atomic
tag string
b *Backend
}
// Trace formats message using the default formats for its operands, prepends
// the prefix as necessary, and writes to log with LevelTrace.
//
// This is part of the Logger interface implementation.
func (l *slog) Trace(args ...interface{}) {
lvl := l.Level()
if lvl <= LevelTrace {
l.b.print("TRC", l.tag, args...)
}
}
// Tracef formats message according to format specifier, prepends the prefix as
// necessary, and writes to log with LevelTrace.
//
// This is part of the Logger interface implementation.
func (l *slog) Tracef(format string, args ...interface{}) {
lvl := l.Level()
if lvl <= LevelTrace {
l.b.printf("TRC", l.tag, format, args...)
}
}
// Debug formats message using the default formats for its operands, prepends
// the prefix as necessary, and writes to log with LevelDebug.
//
// This is part of the Logger interface implementation.
func (l *slog) Debug(args ...interface{}) {
lvl := l.Level()
if lvl <= LevelDebug {
l.b.print("DBG", l.tag, args...)
}
}
// Debugf formats message according to format specifier, prepends the prefix as
// necessary, and writes to log with LevelDebug.
//
// This is part of the Logger interface implementation.
func (l *slog) Debugf(format string, args ...interface{}) {
lvl := l.Level()
if lvl <= LevelDebug {
l.b.printf("DBG", l.tag, format, args...)
}
}
// Info formats message using the default formats for its operands, prepends
// the prefix as necessary, and writes to log with LevelInfo.
//
// This is part of the Logger interface implementation.
func (l *slog) Info(args ...interface{}) {
lvl := l.Level()
if lvl <= LevelInfo {
l.b.print("INF", l.tag, args...)
}
}
// Infof formats message according to format specifier, prepends the prefix as
// necessary, and writes to log with LevelInfo.
//
// This is part of the Logger interface implementation.
func (l *slog) Infof(format string, args ...interface{}) {
lvl := l.Level()
if lvl <= LevelInfo {
l.b.printf("INF", l.tag, format, args...)
}
}
// Warn formats message using the default formats for its operands, prepends
// the prefix as necessary, and writes to log with LevelWarn.
//
// This is part of the Logger interface implementation.
func (l *slog) Warn(args ...interface{}) {
lvl := l.Level()
if lvl <= LevelWarn {
l.b.print("WRN", l.tag, args...)
}
}
// Warnf formats message according to format specifier, prepends the prefix as
// necessary, and writes to log with LevelWarn.
//
// This is part of the Logger interface implementation.
func (l *slog) Warnf(format string, args ...interface{}) {
lvl := l.Level()
if lvl <= LevelWarn {
l.b.printf("WRN", l.tag, format, args...)
}
}
// Error formats message using the default formats for its operands, prepends
// the prefix as necessary, and writes to log with LevelError.
//
// This is part of the Logger interface implementation.
func (l *slog) Error(args ...interface{}) {
lvl := l.Level()
if lvl <= LevelError {
l.b.print("ERR", l.tag, args...)
}
}
// Errorf formats message according to format specifier, prepends the prefix as
// necessary, and writes to log with LevelError.
//
// This is part of the Logger interface implementation.
func (l *slog) Errorf(format string, args ...interface{}) {
lvl := l.Level()
if lvl <= LevelError {
l.b.printf("ERR", l.tag, format, args...)
}
}
// Critical formats message using the default formats for its operands, prepends
// the prefix as necessary, and writes to log with LevelCritical.
//
// This is part of the Logger interface implementation.
func (l *slog) Critical(args ...interface{}) {
lvl := l.Level()
if lvl <= LevelCritical {
l.b.print("CRT", l.tag, args...)
}
}
// Criticalf formats message according to format specifier, prepends the prefix
// as necessary, and writes to log with LevelCritical.
//
// This is part of the Logger interface implementation.
func (l *slog) Criticalf(format string, args ...interface{}) {
lvl := l.Level()
if lvl <= LevelCritical {
l.b.printf("CRT", l.tag, format, args...)
}
}
// Level returns the current logging level
//
// This is part of the Logger interface implementation.
func (l *slog) Level() Level {
return Level(atomic.LoadUint32((*uint32)(&l.lvl)))
}
// SetLevel changes the logging level to the passed level.
//
// This is part of the Logger interface implementation.
func (l *slog) SetLevel(level Level) {
atomic.StoreUint32((*uint32)(&l.lvl), uint32(level))
}
// Disabled is a Logger that will never output anything.
var Disabled Logger
func init() {
Disabled = &slog{lvl: LevelOff, b: NewBackend(ioutil.Discard)}
}