commit
8dfcbc160d
17
Makefile
17
Makefile
@ -22,8 +22,8 @@ HAVE_LINTER := $(shell command -v $(LINT_BIN) 2> /dev/null)
|
|||||||
|
|
||||||
BTCD_DIR :=${GOPATH}/src/$(BTCD_PKG)
|
BTCD_DIR :=${GOPATH}/src/$(BTCD_PKG)
|
||||||
|
|
||||||
COMMIT := $(shell git rev-parse HEAD)
|
COMMIT := $(shell git describe --abbrev=40 --dirty --broken)
|
||||||
LDFLAGS := -ldflags "-X main.Commit=$(COMMIT)"
|
LDFLAGS := -ldflags "-X $(PKG)/build.Commit=$(COMMIT)"
|
||||||
|
|
||||||
GLIDE_COMMIT := 84607742b10f492430762d038e954236bbaf23f7
|
GLIDE_COMMIT := 84607742b10f492430762d038e954236bbaf23f7
|
||||||
BTCD_COMMIT := $(shell cat Gopkg.toml | \
|
BTCD_COMMIT := $(shell cat Gopkg.toml | \
|
||||||
@ -47,8 +47,11 @@ XARGS := xargs -L 1
|
|||||||
|
|
||||||
include make/testing_flags.mk
|
include make/testing_flags.mk
|
||||||
|
|
||||||
|
DEV_TAGS := $(if ${tags},$(DEV_TAGS) ${tags},$(DEV_TAGS))
|
||||||
|
PROD_TAGS := $(if ${tags},$(PROD_TAGS) ${tags},$(PROD_TAGS))
|
||||||
|
|
||||||
COVER = for dir in $(GOLISTCOVER); do \
|
COVER = for dir in $(GOLISTCOVER); do \
|
||||||
$(GOTEST) -tags="$(TEST_TAGS)" \
|
$(GOTEST) -tags="$(DEV_TAGS) $(LOG_TAGS)" \
|
||||||
-covermode=count \
|
-covermode=count \
|
||||||
-coverprofile=$$dir/profile.tmp $$dir; \
|
-coverprofile=$$dir/profile.tmp $$dir; \
|
||||||
\
|
\
|
||||||
@ -130,13 +133,13 @@ btcd: $(GLIDE_BIN) $(BTCD_DIR)
|
|||||||
|
|
||||||
build:
|
build:
|
||||||
@$(call print, "Building debug lnd and lncli.")
|
@$(call print, "Building debug lnd and lncli.")
|
||||||
$(GOBUILD) -tags="$(TEST_TAGS) ${tags}" -o lnd-debug $(LDFLAGS) $(PKG)
|
$(GOBUILD) -tags="$(DEV_TAGS)" -o lnd-debug $(LDFLAGS) $(PKG)
|
||||||
$(GOBUILD) -tags="$(TEST_TAGS) ${tags}" -o lncli-debug $(LDFLAGS) $(PKG)/cmd/lncli
|
$(GOBUILD) -tags="$(DEV_TAGS)" -o lncli-debug $(LDFLAGS) $(PKG)/cmd/lncli
|
||||||
|
|
||||||
install:
|
install:
|
||||||
@$(call print, "Installing lnd and lncli.")
|
@$(call print, "Installing lnd and lncli.")
|
||||||
go install -v -tags="${tags}" $(LDFLAGS) $(PKG)
|
go install -v -tags="$(PROD_TAGS)" $(LDFLAGS) $(PKG)
|
||||||
go install -v -tags="${tags}" $(LDFLAGS) $(PKG)/cmd/lncli
|
go install -v -tags="$(PROD_TAGS)" $(LDFLAGS) $(PKG)/cmd/lncli
|
||||||
|
|
||||||
scratch: dep build
|
scratch: dep build
|
||||||
|
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
package autopilot
|
package autopilot
|
||||||
|
|
||||||
import "github.com/btcsuite/btclog"
|
import (
|
||||||
|
"github.com/btcsuite/btclog"
|
||||||
|
"github.com/lightningnetwork/lnd/build"
|
||||||
|
)
|
||||||
|
|
||||||
// log is a logger that is initialized with no output filters. This
|
// log is a logger that is initialized with no output filters. This
|
||||||
// means the package will not perform any logging by default until the caller
|
// means the package will not perform any logging by default until the caller
|
||||||
@ -9,13 +12,13 @@ var log btclog.Logger
|
|||||||
|
|
||||||
// The default amount of logging is none.
|
// The default amount of logging is none.
|
||||||
func init() {
|
func init() {
|
||||||
DisableLog()
|
UseLogger(build.NewSubLogger("ATPL", nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
// DisableLog disables all library log output. Logging output is disabled
|
// DisableLog disables all library log output. Logging output is disabled
|
||||||
// by default until UseLogger is called.
|
// by default until UseLogger is called.
|
||||||
func DisableLog() {
|
func DisableLog() {
|
||||||
log = btclog.Disabled
|
UseLogger(btclog.Disabled)
|
||||||
}
|
}
|
||||||
|
|
||||||
// UseLogger uses a specified Logger to output package logging info.
|
// UseLogger uses a specified Logger to output package logging info.
|
||||||
|
@ -15,6 +15,7 @@ import (
|
|||||||
"github.com/btcsuite/btcutil"
|
"github.com/btcsuite/btcutil"
|
||||||
"github.com/coreos/bbolt"
|
"github.com/coreos/bbolt"
|
||||||
"github.com/davecgh/go-spew/spew"
|
"github.com/davecgh/go-spew/spew"
|
||||||
|
|
||||||
"github.com/lightningnetwork/lnd/chainntnfs"
|
"github.com/lightningnetwork/lnd/chainntnfs"
|
||||||
"github.com/lightningnetwork/lnd/channeldb"
|
"github.com/lightningnetwork/lnd/channeldb"
|
||||||
"github.com/lightningnetwork/lnd/htlcswitch"
|
"github.com/lightningnetwork/lnd/htlcswitch"
|
||||||
|
@ -22,7 +22,6 @@ import (
|
|||||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||||
"github.com/btcsuite/btcd/txscript"
|
"github.com/btcsuite/btcd/txscript"
|
||||||
"github.com/btcsuite/btcd/wire"
|
"github.com/btcsuite/btcd/wire"
|
||||||
"github.com/btcsuite/btclog"
|
|
||||||
"github.com/btcsuite/btcutil"
|
"github.com/btcsuite/btcutil"
|
||||||
"github.com/go-errors/errors"
|
"github.com/go-errors/errors"
|
||||||
"github.com/lightningnetwork/lnd/chainntnfs"
|
"github.com/lightningnetwork/lnd/chainntnfs"
|
||||||
@ -268,10 +267,6 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
channeldb.UseLogger(btclog.Disabled)
|
|
||||||
lnwallet.UseLogger(btclog.Disabled)
|
|
||||||
brarLog = btclog.Disabled
|
|
||||||
|
|
||||||
// Ensure that breached outputs are initialized before starting tests.
|
// Ensure that breached outputs are initialized before starting tests.
|
||||||
if err := initBreachedOutputs(); err != nil {
|
if err := initBreachedOutputs(); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
36
build/deployment.go
Normal file
36
build/deployment.go
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
package build
|
||||||
|
|
||||||
|
// DeploymentType is an enum specifying the deployment to compile.
|
||||||
|
type DeploymentType byte
|
||||||
|
|
||||||
|
const (
|
||||||
|
// Development is a deployment that includes extra testing hooks and
|
||||||
|
// logging configurations.
|
||||||
|
Development DeploymentType = iota
|
||||||
|
|
||||||
|
// Production is a deployment that strips out testing logic and uses
|
||||||
|
// Default logging.
|
||||||
|
Production
|
||||||
|
)
|
||||||
|
|
||||||
|
// String returns a human readable name for a build type.
|
||||||
|
func (b DeploymentType) String() string {
|
||||||
|
switch b {
|
||||||
|
case Development:
|
||||||
|
return "development"
|
||||||
|
case Production:
|
||||||
|
return "production"
|
||||||
|
default:
|
||||||
|
return "unknown"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsProdBuild returns true if this is a production build.
|
||||||
|
func IsProdBuild() bool {
|
||||||
|
return Deployment == Production
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsDevBuild returns true if this is a development build.
|
||||||
|
func IsDevBuild() bool {
|
||||||
|
return Deployment == Development
|
||||||
|
}
|
6
build/deployment_dev.go
Normal file
6
build/deployment_dev.go
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
// +build dev
|
||||||
|
|
||||||
|
package build
|
||||||
|
|
||||||
|
// Deployment specifies a development build.
|
||||||
|
const Deployment = Development
|
6
build/deployment_prod.go
Normal file
6
build/deployment_prod.go
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
// +build !dev
|
||||||
|
|
||||||
|
package build
|
||||||
|
|
||||||
|
// Deployment specifies a production build.
|
||||||
|
const Deployment = Production
|
95
build/log.go
Normal file
95
build/log.go
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
package build
|
||||||
|
|
||||||
|
import (
|
||||||
|
"io"
|
||||||
|
|
||||||
|
"github.com/btcsuite/btclog"
|
||||||
|
)
|
||||||
|
|
||||||
|
// LogType is an indicating the type of logging specified by the build flag.
|
||||||
|
type LogType byte
|
||||||
|
|
||||||
|
const (
|
||||||
|
// LogTypeNone indicates no logging.
|
||||||
|
LogTypeNone LogType = iota
|
||||||
|
|
||||||
|
// LogTypeStdOut all logging is written directly to stdout.
|
||||||
|
LogTypeStdOut
|
||||||
|
|
||||||
|
// LogTypeDefault logs to both stdout and a given io.PipeWriter.
|
||||||
|
LogTypeDefault
|
||||||
|
)
|
||||||
|
|
||||||
|
// String returns a human readable identifier for the logging type.
|
||||||
|
func (t LogType) String() string {
|
||||||
|
switch t {
|
||||||
|
case LogTypeNone:
|
||||||
|
return "none"
|
||||||
|
case LogTypeStdOut:
|
||||||
|
return "stdout"
|
||||||
|
case LogTypeDefault:
|
||||||
|
return "default"
|
||||||
|
default:
|
||||||
|
return "unknown"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// LogWriter is a stub type whose behavior can be changed using the build flags
|
||||||
|
// "stdlog" and "nolog". The default behavior is to write to both stdout and the
|
||||||
|
// RotatorPipe. Passing "stdlog" will cause it only to write to stdout, and
|
||||||
|
// "nolog" implements Write as a no-op.
|
||||||
|
type LogWriter struct {
|
||||||
|
// RotatorPipe is the write-end pipe for writing to the log rotator. It
|
||||||
|
// is written to by the Write method of the LogWriter type. This only
|
||||||
|
// needs to be set if neither the stdlog or nolog builds are set.
|
||||||
|
RotatorPipe *io.PipeWriter
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewSubLogger constructs a new subsystem log from the current LogWriter
|
||||||
|
// implementation. This is primarily intended for use with stdlog, as the actual
|
||||||
|
// writer is shared amongst all instantiations.
|
||||||
|
func NewSubLogger(subsystem string,
|
||||||
|
genSubLogger func(string) btclog.Logger) btclog.Logger {
|
||||||
|
|
||||||
|
switch Deployment {
|
||||||
|
|
||||||
|
// For production builds, generate a new subsystem logger from the
|
||||||
|
// primary log backend. If no function is provided, logging will be
|
||||||
|
// disabled.
|
||||||
|
case Production:
|
||||||
|
if genSubLogger != nil {
|
||||||
|
return genSubLogger(subsystem)
|
||||||
|
}
|
||||||
|
|
||||||
|
// For development builds, we must handle two distinct types of logging:
|
||||||
|
// unit tests and running the live daemon, e.g. for integration testing.
|
||||||
|
case Development:
|
||||||
|
switch LoggingType {
|
||||||
|
|
||||||
|
// Default logging is used when running the standalone daemon.
|
||||||
|
// We'll use the optional sublogger constructor to mimic the
|
||||||
|
// production behavior.
|
||||||
|
case LogTypeDefault:
|
||||||
|
if genSubLogger != nil {
|
||||||
|
return genSubLogger(subsystem)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Logging to stdout is used in unit tests. It is not important
|
||||||
|
// that they share the same backend, since all output is written
|
||||||
|
// to std out.
|
||||||
|
case LogTypeStdOut:
|
||||||
|
backend := btclog.NewBackend(&LogWriter{})
|
||||||
|
logger := backend.Logger(subsystem)
|
||||||
|
|
||||||
|
// Set the logging level of the stdout logger to use the
|
||||||
|
// configured logging level specified by build flags.
|
||||||
|
level, _ := btclog.LevelFromString(LogLevel)
|
||||||
|
logger.SetLevel(level)
|
||||||
|
|
||||||
|
return logger
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// For any other configurations, we'll disable logging.
|
||||||
|
return btclog.Disabled
|
||||||
|
}
|
18
build/log_default.go
Normal file
18
build/log_default.go
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
// +build !stdlog,!nolog
|
||||||
|
|
||||||
|
package build
|
||||||
|
|
||||||
|
import "os"
|
||||||
|
|
||||||
|
// LoggingType is a log type that writes to both stdout and the log rotator, if
|
||||||
|
// present.
|
||||||
|
const LoggingType = LogTypeDefault
|
||||||
|
|
||||||
|
// Write writes the byte slice to both stdout and the log rotator, if present.
|
||||||
|
func (w *LogWriter) Write(b []byte) (int, error) {
|
||||||
|
os.Stdout.Write(b)
|
||||||
|
if w.RotatorPipe != nil {
|
||||||
|
w.RotatorPipe.Write(b)
|
||||||
|
}
|
||||||
|
return len(b), nil
|
||||||
|
}
|
11
build/log_nolog.go
Normal file
11
build/log_nolog.go
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
// +build nolog
|
||||||
|
|
||||||
|
package build
|
||||||
|
|
||||||
|
// LoggingType is a log type that writes no logs.
|
||||||
|
const LoggingType = LogTypeNone
|
||||||
|
|
||||||
|
// Write is a noop.
|
||||||
|
func (w *LogWriter) Write(b []byte) (int, error) {
|
||||||
|
return len(b), nil
|
||||||
|
}
|
14
build/log_stdlog.go
Normal file
14
build/log_stdlog.go
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
// +build stdlog
|
||||||
|
|
||||||
|
package build
|
||||||
|
|
||||||
|
import "os"
|
||||||
|
|
||||||
|
// LoggingType is a log type that only writes to stdout.
|
||||||
|
const LoggingType = LogTypeStdOut
|
||||||
|
|
||||||
|
// Write writes the provided byte slice to stdout.
|
||||||
|
func (w *LogWriter) Write(b []byte) (int, error) {
|
||||||
|
os.Stdout.Write(b)
|
||||||
|
return len(b), nil
|
||||||
|
}
|
6
build/loglevel_critical.go
Normal file
6
build/loglevel_critical.go
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
// +build dev,critical
|
||||||
|
|
||||||
|
package build
|
||||||
|
|
||||||
|
// LogLevel specifies a critical log level.
|
||||||
|
var LogLevel = "critical"
|
6
build/loglevel_debug.go
Normal file
6
build/loglevel_debug.go
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
// +build dev,debug
|
||||||
|
|
||||||
|
package build
|
||||||
|
|
||||||
|
// LogLevel specifies a debug log level.
|
||||||
|
var LogLevel = "debug"
|
6
build/loglevel_default.go
Normal file
6
build/loglevel_default.go
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
// +build !info,!debug,!trace,!warn,!error,!critical,!off
|
||||||
|
|
||||||
|
package build
|
||||||
|
|
||||||
|
// LogLevel specifies a default log level of info.
|
||||||
|
var LogLevel = "info"
|
6
build/loglevel_error.go
Normal file
6
build/loglevel_error.go
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
// +build dev,error
|
||||||
|
|
||||||
|
package build
|
||||||
|
|
||||||
|
// LogLevel specifies an error log level.
|
||||||
|
var LogLevel = "error"
|
6
build/loglevel_info.go
Normal file
6
build/loglevel_info.go
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
// +build dev,info
|
||||||
|
|
||||||
|
package build
|
||||||
|
|
||||||
|
// LogLevel specifies an info log level.
|
||||||
|
var LogLevel = "info"
|
6
build/loglevel_off.go
Normal file
6
build/loglevel_off.go
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
// +build dev,off
|
||||||
|
|
||||||
|
package build
|
||||||
|
|
||||||
|
// LogLevel specifies an off log level.
|
||||||
|
var LogLevel = "off"
|
6
build/loglevel_trace.go
Normal file
6
build/loglevel_trace.go
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
// +build dev,trace
|
||||||
|
|
||||||
|
package build
|
||||||
|
|
||||||
|
// LogLevel specifies a trace log level.
|
||||||
|
var LogLevel = "trace"
|
6
build/loglevel_warn.go
Normal file
6
build/loglevel_warn.go
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
// +build dev,warn
|
||||||
|
|
||||||
|
package build
|
||||||
|
|
||||||
|
// LogLevel specifies a warning log level.
|
||||||
|
var LogLevel = "warn"
|
@ -3,7 +3,7 @@
|
|||||||
// Heavily inspired by https://github.com/btcsuite/btcd/blob/master/version.go
|
// Heavily inspired by https://github.com/btcsuite/btcd/blob/master/version.go
|
||||||
// Copyright (C) 2015-2017 The Lightning Network Developers
|
// Copyright (C) 2015-2017 The Lightning Network Developers
|
||||||
|
|
||||||
package main
|
package build
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
@ -11,6 +11,10 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Commit stores the current commit hash of this build, this should be set using
|
||||||
|
// the -ldflags during compilation.
|
||||||
|
var Commit string
|
||||||
|
|
||||||
// semanticAlphabet
|
// semanticAlphabet
|
||||||
const semanticAlphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-"
|
const semanticAlphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-"
|
||||||
|
|
||||||
@ -26,14 +30,9 @@ const (
|
|||||||
appPreRelease = "beta"
|
appPreRelease = "beta"
|
||||||
)
|
)
|
||||||
|
|
||||||
// appBuild is defined as a variable so it can be overridden during the build
|
// Version returns the application version as a properly formed string per the
|
||||||
// process with '-ldflags "-X main.appBuild foo' if needed. It MUST only
|
|
||||||
// contain characters from semanticAlphabet per the semantic versioning spec.
|
|
||||||
var appBuild string
|
|
||||||
|
|
||||||
// version returns the application version as a properly formed string per the
|
|
||||||
// semantic versioning 2.0.0 spec (http://semver.org/).
|
// semantic versioning 2.0.0 spec (http://semver.org/).
|
||||||
func version() string {
|
func Version() string {
|
||||||
// Start with the major, minor, and patch versions.
|
// Start with the major, minor, and patch versions.
|
||||||
version := fmt.Sprintf("%d.%d.%d", appMajor, appMinor, appPatch)
|
version := fmt.Sprintf("%d.%d.%d", appMajor, appMinor, appPatch)
|
||||||
|
|
||||||
@ -46,15 +45,6 @@ func version() string {
|
|||||||
version = fmt.Sprintf("%s-%s", version, preRelease)
|
version = fmt.Sprintf("%s-%s", version, preRelease)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Append build metadata if there is any. The plus called for
|
|
||||||
// by the semantic versioning spec is automatically appended and should
|
|
||||||
// not be contained in the build metadata string. The build metadata
|
|
||||||
// string is not appended if it contains invalid characters.
|
|
||||||
build := normalizeVerString(appBuild)
|
|
||||||
if build != "" {
|
|
||||||
version = fmt.Sprintf("%s+%s", version, build)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Append commit hash of current build to version.
|
// Append commit hash of current build to version.
|
||||||
version = fmt.Sprintf("%s commit=%s", version, Commit)
|
version = fmt.Sprintf("%s commit=%s", version, Commit)
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
// +build debug
|
// +build dev
|
||||||
|
|
||||||
package bitcoindnotify
|
package bitcoindnotify
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
// +build debug
|
// +build dev
|
||||||
|
|
||||||
package bitcoindnotify
|
package bitcoindnotify
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// +build debug
|
// +build dev
|
||||||
|
|
||||||
package btcdnotify
|
package btcdnotify
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
// +build debug
|
// +build dev
|
||||||
|
|
||||||
package btcdnotify
|
package btcdnotify
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// +build debug
|
// +build dev
|
||||||
|
|
||||||
package chainntnfs
|
package chainntnfs
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
// +build debug
|
// +build dev
|
||||||
|
|
||||||
package chainntnfs_test
|
package chainntnfs_test
|
||||||
|
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
package chainntnfs
|
package chainntnfs
|
||||||
|
|
||||||
import "github.com/btcsuite/btclog"
|
import (
|
||||||
|
"github.com/btcsuite/btclog"
|
||||||
|
"github.com/lightningnetwork/lnd/build"
|
||||||
|
)
|
||||||
|
|
||||||
// Log is a logger that is initialized with no output filters. This
|
// Log is a logger that is initialized with no output filters. This
|
||||||
// means the package will not perform any logging by default until the caller
|
// means the package will not perform any logging by default until the caller
|
||||||
@ -9,13 +12,13 @@ var Log btclog.Logger
|
|||||||
|
|
||||||
// The default amount of logging is none.
|
// The default amount of logging is none.
|
||||||
func init() {
|
func init() {
|
||||||
DisableLog()
|
UseLogger(build.NewSubLogger("NTFN", nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
// DisableLog disables all library log output. Logging output is disabled
|
// DisableLog disables all library log output. Logging output is disabled
|
||||||
// by default until UseLogger is called.
|
// by default until UseLogger is called.
|
||||||
func DisableLog() {
|
func DisableLog() {
|
||||||
Log = btclog.Disabled
|
UseLogger(btclog.Disabled)
|
||||||
}
|
}
|
||||||
|
|
||||||
// UseLogger uses a specified Logger to output package logging info.
|
// UseLogger uses a specified Logger to output package logging info.
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// +build debug
|
// +build dev
|
||||||
|
|
||||||
package neutrinonotify
|
package neutrinonotify
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
// +build debug
|
// +build dev
|
||||||
|
|
||||||
package chainntnfs
|
package chainntnfs
|
||||||
|
|
||||||
|
@ -1,21 +1,23 @@
|
|||||||
package channeldb
|
package channeldb
|
||||||
|
|
||||||
import "github.com/btcsuite/btclog"
|
import (
|
||||||
|
"github.com/btcsuite/btclog"
|
||||||
|
"github.com/lightningnetwork/lnd/build"
|
||||||
|
)
|
||||||
|
|
||||||
// log is a logger that is initialized with no output filters. This
|
// log is a logger that is initialized with no output filters. This
|
||||||
// means the package will not perform any logging by default until the caller
|
// means the package will not perform any logging by default until the caller
|
||||||
// requests it.
|
// requests it.
|
||||||
var log btclog.Logger
|
var log btclog.Logger
|
||||||
|
|
||||||
// The default amount of logging is none.
|
|
||||||
func init() {
|
func init() {
|
||||||
DisableLog()
|
UseLogger(build.NewSubLogger("CHDB", nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
// DisableLog disables all library log output. Logging output is disabled
|
// DisableLog disables all library log output. Logging output is disabled
|
||||||
// by default until UseLogger is called.
|
// by default until UseLogger is called.
|
||||||
func DisableLog() {
|
func DisableLog() {
|
||||||
log = btclog.Disabled
|
UseLogger(btclog.Disabled)
|
||||||
}
|
}
|
||||||
|
|
||||||
// UseLogger uses a specified Logger to output package logging info.
|
// UseLogger uses a specified Logger to output package logging info.
|
||||||
|
@ -15,6 +15,7 @@ import (
|
|||||||
macaroon "gopkg.in/macaroon.v2"
|
macaroon "gopkg.in/macaroon.v2"
|
||||||
|
|
||||||
"github.com/btcsuite/btcutil"
|
"github.com/btcsuite/btcutil"
|
||||||
|
"github.com/lightningnetwork/lnd/build"
|
||||||
"github.com/lightningnetwork/lnd/lncfg"
|
"github.com/lightningnetwork/lnd/lncfg"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc"
|
"github.com/lightningnetwork/lnd/lnrpc"
|
||||||
"github.com/lightningnetwork/lnd/macaroons"
|
"github.com/lightningnetwork/lnd/macaroons"
|
||||||
@ -34,10 +35,6 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// Commit stores the current commit hash of this build. This should be
|
|
||||||
// set using -ldflags during compilation.
|
|
||||||
Commit string
|
|
||||||
|
|
||||||
defaultLndDir = btcutil.AppDataDir("lnd", false)
|
defaultLndDir = btcutil.AppDataDir("lnd", false)
|
||||||
defaultTLSCertPath = filepath.Join(defaultLndDir, defaultTLSCertFilename)
|
defaultTLSCertPath = filepath.Join(defaultLndDir, defaultTLSCertFilename)
|
||||||
)
|
)
|
||||||
@ -205,7 +202,7 @@ func extractPathArgs(ctx *cli.Context) (string, string, error) {
|
|||||||
func main() {
|
func main() {
|
||||||
app := cli.NewApp()
|
app := cli.NewApp()
|
||||||
app.Name = "lncli"
|
app.Name = "lncli"
|
||||||
app.Version = fmt.Sprintf("%s commit=%s", "0.5", Commit)
|
app.Version = build.Version()
|
||||||
app.Usage = "control plane for your Lightning Network Daemon (lnd)"
|
app.Usage = "control plane for your Lightning Network Daemon (lnd)"
|
||||||
app.Flags = []cli.Flag{
|
app.Flags = []cli.Flag{
|
||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
|
@ -21,6 +21,7 @@ import (
|
|||||||
|
|
||||||
"github.com/btcsuite/btcutil"
|
"github.com/btcsuite/btcutil"
|
||||||
flags "github.com/jessevdk/go-flags"
|
flags "github.com/jessevdk/go-flags"
|
||||||
|
"github.com/lightningnetwork/lnd/build"
|
||||||
"github.com/lightningnetwork/lnd/htlcswitch/hodl"
|
"github.com/lightningnetwork/lnd/htlcswitch/hodl"
|
||||||
"github.com/lightningnetwork/lnd/lncfg"
|
"github.com/lightningnetwork/lnd/lncfg"
|
||||||
"github.com/lightningnetwork/lnd/lnwire"
|
"github.com/lightningnetwork/lnd/lnwire"
|
||||||
@ -323,7 +324,7 @@ func loadConfig() (*config, error) {
|
|||||||
appName = strings.TrimSuffix(appName, filepath.Ext(appName))
|
appName = strings.TrimSuffix(appName, filepath.Ext(appName))
|
||||||
usageMessage := fmt.Sprintf("Use %s -h to show usage", appName)
|
usageMessage := fmt.Sprintf("Use %s -h to show usage", appName)
|
||||||
if preCfg.ShowVersion {
|
if preCfg.ShowVersion {
|
||||||
fmt.Println(appName, "version", version())
|
fmt.Println(appName, "version", build.Version())
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
// +build debug
|
|
||||||
|
|
||||||
package main
|
|
||||||
|
|
||||||
// DebugBuild signals that this is a debug build.
|
|
||||||
const DebugBuild = true
|
|
@ -1,6 +0,0 @@
|
|||||||
// +build !debug
|
|
||||||
|
|
||||||
package main
|
|
||||||
|
|
||||||
// DebugBuild signals that this is a debug build.
|
|
||||||
const DebugBuild = false
|
|
@ -1,6 +1,9 @@
|
|||||||
package contractcourt
|
package contractcourt
|
||||||
|
|
||||||
import "github.com/btcsuite/btclog"
|
import (
|
||||||
|
"github.com/btcsuite/btclog"
|
||||||
|
"github.com/lightningnetwork/lnd/build"
|
||||||
|
)
|
||||||
|
|
||||||
// log is a logger that is initialized with no output filters. This
|
// log is a logger that is initialized with no output filters. This
|
||||||
// means the package will not perform any logging by default until the caller
|
// means the package will not perform any logging by default until the caller
|
||||||
@ -9,13 +12,13 @@ var log btclog.Logger
|
|||||||
|
|
||||||
// The default amount of logging is none.
|
// The default amount of logging is none.
|
||||||
func init() {
|
func init() {
|
||||||
DisableLog()
|
UseLogger(build.NewSubLogger("CNCT", nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
// DisableLog disables all library log output. Logging output is disabled
|
// DisableLog disables all library log output. Logging output is disabled
|
||||||
// by default until UseLogger is called.
|
// by default until UseLogger is called.
|
||||||
func DisableLog() {
|
func DisableLog() {
|
||||||
log = btclog.Disabled
|
UseLogger(btclog.Disabled)
|
||||||
}
|
}
|
||||||
|
|
||||||
// UseLogger uses a specified Logger to output package logging info.
|
// UseLogger uses a specified Logger to output package logging info.
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
package discovery
|
package discovery
|
||||||
|
|
||||||
import "github.com/btcsuite/btclog"
|
import (
|
||||||
|
"github.com/btcsuite/btclog"
|
||||||
|
"github.com/lightningnetwork/lnd/build"
|
||||||
|
)
|
||||||
|
|
||||||
// log is a logger that is initialized with no output filters. This
|
// log is a logger that is initialized with no output filters. This
|
||||||
// means the package will not perform any logging by default until the caller
|
// means the package will not perform any logging by default until the caller
|
||||||
@ -9,13 +12,13 @@ var log btclog.Logger
|
|||||||
|
|
||||||
// The default amount of logging is none.
|
// The default amount of logging is none.
|
||||||
func init() {
|
func init() {
|
||||||
DisableLog()
|
UseLogger(build.NewSubLogger("DISC", nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
// DisableLog disables all library log output. Logging output is disabled
|
// DisableLog disables all library log output. Logging output is disabled
|
||||||
// by default until UseLogger is called.
|
// by default until UseLogger is called.
|
||||||
func DisableLog() {
|
func DisableLog() {
|
||||||
log = btclog.Disabled
|
UseLogger(btclog.Disabled)
|
||||||
}
|
}
|
||||||
|
|
||||||
// UseLogger uses a specified Logger to output package logging info.
|
// UseLogger uses a specified Logger to output package logging info.
|
||||||
|
@ -160,6 +160,8 @@ Arguments:
|
|||||||
- `pkg=<package>`
|
- `pkg=<package>`
|
||||||
- `case=<testcase>`
|
- `case=<testcase>`
|
||||||
- `timeout=<timeout>`
|
- `timeout=<timeout>`
|
||||||
|
- `log="stdlog[ <log-level>]"` prints logs to stdout
|
||||||
|
- `<log-level>` can be `info` (default), `debug`, `trace`, `warn`, `error`, `critical`, or `off`
|
||||||
|
|
||||||
`unit-cover`
|
`unit-cover`
|
||||||
------------
|
------------
|
||||||
@ -170,6 +172,8 @@ Arguments:
|
|||||||
- `pkg=<package>`
|
- `pkg=<package>`
|
||||||
- `case=<testcase>`
|
- `case=<testcase>`
|
||||||
- `timeout=<timeout>`
|
- `timeout=<timeout>`
|
||||||
|
- `log="stdlog[ <log-level>]"` prints logs to stdout
|
||||||
|
- `<log-level>` can be `info` (default), `debug`, `trace`, `warn`, `error`, `critical`, or `off`
|
||||||
|
|
||||||
Related: [`unit`](#unit)
|
Related: [`unit`](#unit)
|
||||||
|
|
||||||
@ -181,6 +185,8 @@ Arguments:
|
|||||||
- `pkg=<package>`
|
- `pkg=<package>`
|
||||||
- `case=<testcase>`
|
- `case=<testcase>`
|
||||||
- `timeout=<timeout>`
|
- `timeout=<timeout>`
|
||||||
|
- `log="stdlog[ <log-level>]"` prints logs to stdout
|
||||||
|
- `<log-level>` can be `info` (default), `debug`, `trace`, `warn`, `error`, `critical`, or `off`
|
||||||
|
|
||||||
Related: [`unit`](#unit)
|
Related: [`unit`](#unit)
|
||||||
|
|
||||||
|
@ -15,6 +15,9 @@ import (
|
|||||||
"github.com/coreos/bbolt"
|
"github.com/coreos/bbolt"
|
||||||
"github.com/davecgh/go-spew/spew"
|
"github.com/davecgh/go-spew/spew"
|
||||||
"github.com/go-errors/errors"
|
"github.com/go-errors/errors"
|
||||||
|
"golang.org/x/crypto/salsa20"
|
||||||
|
"google.golang.org/grpc"
|
||||||
|
|
||||||
"github.com/lightningnetwork/lnd/chainntnfs"
|
"github.com/lightningnetwork/lnd/chainntnfs"
|
||||||
"github.com/lightningnetwork/lnd/channeldb"
|
"github.com/lightningnetwork/lnd/channeldb"
|
||||||
"github.com/lightningnetwork/lnd/htlcswitch"
|
"github.com/lightningnetwork/lnd/htlcswitch"
|
||||||
@ -24,8 +27,6 @@ import (
|
|||||||
"github.com/lightningnetwork/lnd/lnwallet"
|
"github.com/lightningnetwork/lnd/lnwallet"
|
||||||
"github.com/lightningnetwork/lnd/lnwire"
|
"github.com/lightningnetwork/lnd/lnwire"
|
||||||
"github.com/lightningnetwork/lnd/routing"
|
"github.com/lightningnetwork/lnd/routing"
|
||||||
"golang.org/x/crypto/salsa20"
|
|
||||||
"google.golang.org/grpc"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -18,12 +18,10 @@ import (
|
|||||||
"github.com/btcsuite/btcd/chaincfg"
|
"github.com/btcsuite/btcd/chaincfg"
|
||||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||||
"github.com/btcsuite/btcd/wire"
|
"github.com/btcsuite/btcd/wire"
|
||||||
"github.com/btcsuite/btclog"
|
|
||||||
"github.com/btcsuite/btcutil"
|
"github.com/btcsuite/btcutil"
|
||||||
_ "github.com/btcsuite/btcwallet/walletdb/bdb"
|
|
||||||
"github.com/lightningnetwork/lnd/chainntnfs"
|
"github.com/lightningnetwork/lnd/chainntnfs"
|
||||||
"github.com/lightningnetwork/lnd/channeldb"
|
"github.com/lightningnetwork/lnd/channeldb"
|
||||||
"github.com/lightningnetwork/lnd/contractcourt"
|
|
||||||
"github.com/lightningnetwork/lnd/htlcswitch"
|
"github.com/lightningnetwork/lnd/htlcswitch"
|
||||||
"github.com/lightningnetwork/lnd/keychain"
|
"github.com/lightningnetwork/lnd/keychain"
|
||||||
"github.com/lightningnetwork/lnd/lnpeer"
|
"github.com/lightningnetwork/lnd/lnpeer"
|
||||||
@ -201,13 +199,6 @@ func (n *testNode) AddNewChannel(channel *channeldb.OpenChannel,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
|
||||||
channeldb.UseLogger(btclog.Disabled)
|
|
||||||
lnwallet.UseLogger(btclog.Disabled)
|
|
||||||
contractcourt.UseLogger(btclog.Disabled)
|
|
||||||
fndgLog = btclog.Disabled
|
|
||||||
}
|
|
||||||
|
|
||||||
func createTestWallet(cdb *channeldb.DB, netParams *chaincfg.Params,
|
func createTestWallet(cdb *channeldb.DB, netParams *chaincfg.Params,
|
||||||
notifier chainntnfs.ChainNotifier, wc lnwallet.WalletController,
|
notifier chainntnfs.ChainNotifier, wc lnwallet.WalletController,
|
||||||
signer lnwallet.Signer, keyRing keychain.SecretKeyRing,
|
signer lnwallet.Signer, keyRing keychain.SecretKeyRing,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// +build debug
|
// +build dev
|
||||||
|
|
||||||
package hodl
|
package hodl
|
||||||
|
|
||||||
@ -61,7 +61,7 @@ func (c *Config) Mask() Mask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: The value returned here will only honor the configuration if
|
// NOTE: The value returned here will only honor the configuration if
|
||||||
// the debug build flag is present. In production, this method always
|
// the dev build flag is present. In production, this method always
|
||||||
// returns hodl.MaskNone and Active(*) always returns false.
|
// returns hodl.MaskNone and Active(*) always returns false.
|
||||||
return MaskFromFlags(flags...)
|
return MaskFromFlags(flags...)
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
// +build !debug
|
// +build !dev
|
||||||
|
|
||||||
package hodl
|
package hodl
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
// +build debug
|
// +build dev
|
||||||
|
|
||||||
package hodl
|
package hodl
|
||||||
|
|
||||||
@ -7,9 +7,6 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
// DebugBuild signals that this is a debug build.
|
|
||||||
const DebugBuild = true
|
|
||||||
|
|
||||||
// MaskFromFlags merges a variadic set of Flags into a single Mask.
|
// MaskFromFlags merges a variadic set of Flags into a single Mask.
|
||||||
func MaskFromFlags(flags ...Flag) Mask {
|
func MaskFromFlags(flags ...Flag) Mask {
|
||||||
var mask Mask
|
var mask Mask
|
@ -1,10 +1,7 @@
|
|||||||
// +build !debug
|
// +build !dev
|
||||||
|
|
||||||
package hodl
|
package hodl
|
||||||
|
|
||||||
// DebugBuild signals that this is a production build.
|
|
||||||
const DebugBuild = false
|
|
||||||
|
|
||||||
// MaskFromFlags in production always returns MaskNone.
|
// MaskFromFlags in production always returns MaskNone.
|
||||||
func MaskFromFlags(_ ...Flag) Mask {
|
func MaskFromFlags(_ ...Flag) Mask {
|
||||||
return MaskNone
|
return MaskNone
|
@ -3,6 +3,7 @@ package hodl_test
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/lightningnetwork/lnd/build"
|
||||||
"github.com/lightningnetwork/lnd/htlcswitch/hodl"
|
"github.com/lightningnetwork/lnd/htlcswitch/hodl"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -87,8 +88,8 @@ var hodlMaskTests = []struct {
|
|||||||
// correctly reports active for flags in the tests' expected flags, and inactive
|
// correctly reports active for flags in the tests' expected flags, and inactive
|
||||||
// for all others.
|
// for all others.
|
||||||
func TestMask(t *testing.T) {
|
func TestMask(t *testing.T) {
|
||||||
if !hodl.DebugBuild {
|
if !build.IsDevBuild() {
|
||||||
t.Fatalf("htlcswitch tests must be run with '-tags debug'")
|
t.Fatalf("htlcswitch tests must be run with '-tags=dev'")
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, test := range hodlMaskTests {
|
for i, test := range hodlMaskTests {
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
package htlcswitch
|
package htlcswitch
|
||||||
|
|
||||||
import "github.com/btcsuite/btclog"
|
import (
|
||||||
|
"github.com/btcsuite/btclog"
|
||||||
|
"github.com/lightningnetwork/lnd/build"
|
||||||
|
)
|
||||||
|
|
||||||
// log is a logger that is initialized with no output filters. This
|
// log is a logger that is initialized with no output filters. This
|
||||||
// means the package will not perform any logging by default until the caller
|
// means the package will not perform any logging by default until the caller
|
||||||
@ -9,13 +12,13 @@ var log btclog.Logger
|
|||||||
|
|
||||||
// The default amount of logging is none.
|
// The default amount of logging is none.
|
||||||
func init() {
|
func init() {
|
||||||
DisableLog()
|
UseLogger(build.NewSubLogger("HSWC", nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
// DisableLog disables all library log output. Logging output is disabled
|
// DisableLog disables all library log output. Logging output is disabled
|
||||||
// by default until UseLogger is called.
|
// by default until UseLogger is called.
|
||||||
func DisableLog() {
|
func DisableLog() {
|
||||||
log = btclog.Disabled
|
UseLogger(btclog.Disabled)
|
||||||
}
|
}
|
||||||
|
|
||||||
// UseLogger uses a specified Logger to output package logging info.
|
// UseLogger uses a specified Logger to output package logging info.
|
||||||
|
16
lnd.go
16
lnd.go
@ -37,6 +37,8 @@ import (
|
|||||||
"github.com/btcsuite/btcwallet/wallet"
|
"github.com/btcsuite/btcwallet/wallet"
|
||||||
proxy "github.com/grpc-ecosystem/grpc-gateway/runtime"
|
proxy "github.com/grpc-ecosystem/grpc-gateway/runtime"
|
||||||
flags "github.com/jessevdk/go-flags"
|
flags "github.com/jessevdk/go-flags"
|
||||||
|
|
||||||
|
"github.com/lightningnetwork/lnd/build"
|
||||||
"github.com/lightningnetwork/lnd/channeldb"
|
"github.com/lightningnetwork/lnd/channeldb"
|
||||||
"github.com/lightningnetwork/lnd/keychain"
|
"github.com/lightningnetwork/lnd/keychain"
|
||||||
"github.com/lightningnetwork/lnd/lncfg"
|
"github.com/lightningnetwork/lnd/lncfg"
|
||||||
@ -54,10 +56,6 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// Commit stores the current commit hash of this build. This should be
|
|
||||||
// set using -ldflags during compilation.
|
|
||||||
Commit string
|
|
||||||
|
|
||||||
cfg *config
|
cfg *config
|
||||||
registeredChains = newChainRegistry()
|
registeredChains = newChainRegistry()
|
||||||
|
|
||||||
@ -93,12 +91,6 @@ var (
|
|||||||
// defers created in the top-level scope of a main method aren't executed if
|
// defers created in the top-level scope of a main method aren't executed if
|
||||||
// os.Exit() is called.
|
// os.Exit() is called.
|
||||||
func lndMain() error {
|
func lndMain() error {
|
||||||
defer func() {
|
|
||||||
if logRotatorPipe != nil {
|
|
||||||
ltndLog.Info("Shutdown complete")
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
// Load the configuration, and parse any command line options. This
|
// Load the configuration, and parse any command line options. This
|
||||||
// function will also set up logging properly.
|
// function will also set up logging properly.
|
||||||
loadedConfig, err := loadConfig()
|
loadedConfig, err := loadConfig()
|
||||||
@ -108,12 +100,14 @@ func lndMain() error {
|
|||||||
cfg = loadedConfig
|
cfg = loadedConfig
|
||||||
defer func() {
|
defer func() {
|
||||||
if logRotator != nil {
|
if logRotator != nil {
|
||||||
|
ltndLog.Info("Shutdown complete")
|
||||||
logRotator.Close()
|
logRotator.Close()
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// Show version at startup.
|
// Show version at startup.
|
||||||
ltndLog.Infof("Version %s", version())
|
ltndLog.Infof("Version: %s, build=%s, logging=%s",
|
||||||
|
build.Version(), build.Deployment, build.LoggingType)
|
||||||
|
|
||||||
var network string
|
var network string
|
||||||
switch {
|
switch {
|
||||||
|
@ -5,6 +5,8 @@ import (
|
|||||||
"github.com/btcsuite/btcwallet/chain"
|
"github.com/btcsuite/btcwallet/chain"
|
||||||
btcwallet "github.com/btcsuite/btcwallet/wallet"
|
btcwallet "github.com/btcsuite/btcwallet/wallet"
|
||||||
"github.com/btcsuite/btcwallet/wtxmgr"
|
"github.com/btcsuite/btcwallet/wtxmgr"
|
||||||
|
|
||||||
|
"github.com/lightningnetwork/lnd/build"
|
||||||
)
|
)
|
||||||
|
|
||||||
// walletLog is a logger that is initialized with no output filters. This
|
// walletLog is a logger that is initialized with no output filters. This
|
||||||
@ -14,13 +16,13 @@ var walletLog btclog.Logger
|
|||||||
|
|
||||||
// The default amount of logging is none.
|
// The default amount of logging is none.
|
||||||
func init() {
|
func init() {
|
||||||
DisableLog()
|
UseLogger(build.NewSubLogger("LNWL", nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
// DisableLog disables all library log output. Logging output is disabled
|
// DisableLog disables all library log output. Logging output is disabled
|
||||||
// by default until UseLogger is called.
|
// by default until UseLogger is called.
|
||||||
func DisableLog() {
|
func DisableLog() {
|
||||||
walletLog = btclog.Disabled
|
UseLogger(btclog.Disabled)
|
||||||
}
|
}
|
||||||
|
|
||||||
// UseLogger uses a specified Logger to output package logging info.
|
// UseLogger uses a specified Logger to output package logging info.
|
||||||
|
58
log.go
58
log.go
@ -12,8 +12,10 @@ import (
|
|||||||
"github.com/btcsuite/btclog"
|
"github.com/btcsuite/btclog"
|
||||||
"github.com/jrick/logrotate/rotator"
|
"github.com/jrick/logrotate/rotator"
|
||||||
"github.com/lightninglabs/neutrino"
|
"github.com/lightninglabs/neutrino"
|
||||||
|
|
||||||
"github.com/lightningnetwork/lightning-onion"
|
"github.com/lightningnetwork/lightning-onion"
|
||||||
"github.com/lightningnetwork/lnd/autopilot"
|
"github.com/lightningnetwork/lnd/autopilot"
|
||||||
|
"github.com/lightningnetwork/lnd/build"
|
||||||
"github.com/lightningnetwork/lnd/chainntnfs"
|
"github.com/lightningnetwork/lnd/chainntnfs"
|
||||||
"github.com/lightningnetwork/lnd/channeldb"
|
"github.com/lightningnetwork/lnd/channeldb"
|
||||||
"github.com/lightningnetwork/lnd/contractcourt"
|
"github.com/lightningnetwork/lnd/contractcourt"
|
||||||
@ -24,16 +26,6 @@ import (
|
|||||||
"github.com/lightningnetwork/lnd/signal"
|
"github.com/lightningnetwork/lnd/signal"
|
||||||
)
|
)
|
||||||
|
|
||||||
// logWriter implements an io.Writer that outputs to both standard output and
|
|
||||||
// the write-end pipe of an initialized log rotator.
|
|
||||||
type logWriter struct{}
|
|
||||||
|
|
||||||
func (logWriter) Write(p []byte) (n int, err error) {
|
|
||||||
os.Stdout.Write(p)
|
|
||||||
logRotatorPipe.Write(p)
|
|
||||||
return len(p), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Loggers per subsystem. A single backend logger is created and all subsystem
|
// Loggers per subsystem. A single backend logger is created and all subsystem
|
||||||
// loggers created from it will write to the backend. When adding new
|
// loggers created from it will write to the backend. When adding new
|
||||||
// subsystems, add the subsystem logger variable here and to the
|
// subsystems, add the subsystem logger variable here and to the
|
||||||
@ -43,38 +35,36 @@ func (logWriter) Write(p []byte) (n int, err error) {
|
|||||||
// log file. This must be performed early during application startup by
|
// log file. This must be performed early during application startup by
|
||||||
// calling initLogRotator.
|
// calling initLogRotator.
|
||||||
var (
|
var (
|
||||||
|
logWriter = &build.LogWriter{}
|
||||||
|
|
||||||
// backendLog is the logging backend used to create all subsystem
|
// backendLog is the logging backend used to create all subsystem
|
||||||
// loggers. The backend must not be used before the log rotator has
|
// loggers. The backend must not be used before the log rotator has
|
||||||
// been initialized, or data races and/or nil pointer dereferences will
|
// been initialized, or data races and/or nil pointer dereferences will
|
||||||
// occur.
|
// occur.
|
||||||
backendLog = btclog.NewBackend(logWriter{})
|
backendLog = btclog.NewBackend(logWriter)
|
||||||
|
|
||||||
// logRotator is one of the logging outputs. It should be closed on
|
// logRotator is one of the logging outputs. It should be closed on
|
||||||
// application shutdown.
|
// application shutdown.
|
||||||
logRotator *rotator.Rotator
|
logRotator *rotator.Rotator
|
||||||
|
|
||||||
// logRotatorPipe is the write-end pipe for writing to the log rotator.
|
ltndLog = build.NewSubLogger("LTND", backendLog.Logger)
|
||||||
// It is written to by the Write method of the logWriter type.
|
lnwlLog = build.NewSubLogger("LNWL", backendLog.Logger)
|
||||||
logRotatorPipe *io.PipeWriter
|
peerLog = build.NewSubLogger("PEER", backendLog.Logger)
|
||||||
|
discLog = build.NewSubLogger("DISC", backendLog.Logger)
|
||||||
ltndLog = backendLog.Logger("LTND")
|
rpcsLog = build.NewSubLogger("RPCS", backendLog.Logger)
|
||||||
lnwlLog = backendLog.Logger("LNWL")
|
srvrLog = build.NewSubLogger("SRVR", backendLog.Logger)
|
||||||
peerLog = backendLog.Logger("PEER")
|
ntfnLog = build.NewSubLogger("NTFN", backendLog.Logger)
|
||||||
discLog = backendLog.Logger("DISC")
|
chdbLog = build.NewSubLogger("CHDB", backendLog.Logger)
|
||||||
rpcsLog = backendLog.Logger("RPCS")
|
fndgLog = build.NewSubLogger("FNDG", backendLog.Logger)
|
||||||
srvrLog = backendLog.Logger("SRVR")
|
hswcLog = build.NewSubLogger("HSWC", backendLog.Logger)
|
||||||
ntfnLog = backendLog.Logger("NTFN")
|
utxnLog = build.NewSubLogger("UTXN", backendLog.Logger)
|
||||||
chdbLog = backendLog.Logger("CHDB")
|
brarLog = build.NewSubLogger("BRAR", backendLog.Logger)
|
||||||
fndgLog = backendLog.Logger("FNDG")
|
cmgrLog = build.NewSubLogger("CMGR", backendLog.Logger)
|
||||||
hswcLog = backendLog.Logger("HSWC")
|
crtrLog = build.NewSubLogger("CRTR", backendLog.Logger)
|
||||||
utxnLog = backendLog.Logger("UTXN")
|
btcnLog = build.NewSubLogger("BTCN", backendLog.Logger)
|
||||||
brarLog = backendLog.Logger("BRAR")
|
atplLog = build.NewSubLogger("ATPL", backendLog.Logger)
|
||||||
cmgrLog = backendLog.Logger("CMGR")
|
cnctLog = build.NewSubLogger("CNCT", backendLog.Logger)
|
||||||
crtrLog = backendLog.Logger("CRTR")
|
sphxLog = build.NewSubLogger("SPHX", backendLog.Logger)
|
||||||
btcnLog = backendLog.Logger("BTCN")
|
|
||||||
atplLog = backendLog.Logger("ATPL")
|
|
||||||
cnctLog = backendLog.Logger("CNCT")
|
|
||||||
sphxLog = backendLog.Logger("SPHX")
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Initialize package-global logger variables.
|
// Initialize package-global logger variables.
|
||||||
@ -134,8 +124,8 @@ func initLogRotator(logFile string, MaxLogFileSize int, MaxLogFiles int) {
|
|||||||
pr, pw := io.Pipe()
|
pr, pw := io.Pipe()
|
||||||
go r.Run(pr)
|
go r.Run(pr)
|
||||||
|
|
||||||
|
logWriter.RotatorPipe = pw
|
||||||
logRotator = r
|
logRotator = r
|
||||||
logRotatorPipe = pw
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// setLogLevel sets the logging level for provided subsystem. Invalid
|
// setLogLevel sets the logging level for provided subsystem. Invalid
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
TEST_TAGS = debug
|
DEV_TAGS = dev
|
||||||
|
PROD_TAGS = prod
|
||||||
|
LOG_TAGS =
|
||||||
TEST_FLAGS =
|
TEST_FLAGS =
|
||||||
|
|
||||||
# If specific package is being unit tested, construct the full name of the
|
# If specific package is being unit tested, construct the full name of the
|
||||||
@ -19,6 +21,14 @@ ifneq ($(icase),)
|
|||||||
TEST_FLAGS += -test.run=TestLightningNetworkDaemon/$(icase)
|
TEST_FLAGS += -test.run=TestLightningNetworkDaemon/$(icase)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
# Define the log tags that will be applied only when running unit tests. If none
|
||||||
|
# are provided, we default to "nolog" which will be silent.
|
||||||
|
ifneq ($(log),)
|
||||||
|
LOG_TAGS := ${log}
|
||||||
|
else
|
||||||
|
LOG_TAGS := nolog
|
||||||
|
endif
|
||||||
|
|
||||||
# If a timeout was requested, construct initialize the proper flag for the go
|
# If a timeout was requested, construct initialize the proper flag for the go
|
||||||
# test command. If not, we set 20m (up from the default 10m).
|
# test command. If not, we set 20m (up from the default 10m).
|
||||||
ifneq ($(timeout),)
|
ifneq ($(timeout),)
|
||||||
@ -34,16 +44,16 @@ UNIT_TARGETED ?= no
|
|||||||
# If a specific package/test case was requested, run the unit test for the
|
# If a specific package/test case was requested, run the unit test for the
|
||||||
# targeted case. Otherwise, default to running all tests.
|
# targeted case. Otherwise, default to running all tests.
|
||||||
ifeq ($(UNIT_TARGETED), yes)
|
ifeq ($(UNIT_TARGETED), yes)
|
||||||
UNIT := $(GOTEST) -tags="$(TEST_TAGS)" $(TEST_FLAGS) $(UNITPKG)
|
UNIT := $(GOTEST) -tags="$(DEV_TAGS) $(LOG_TAGS)" $(TEST_FLAGS) $(UNITPKG)
|
||||||
UNIT_RACE := $(GOTEST) -tags="$(TEST_TAGS)" $(TEST_FLAGS) -race $(UNITPKG)
|
UNIT_RACE := $(GOTEST) -tags="$(DEV_TAGS) $(LOG_TAGS)" $(TEST_FLAGS) -race $(UNITPKG)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(UNIT_TARGETED), no)
|
ifeq ($(UNIT_TARGETED), no)
|
||||||
UNIT := $(GOLIST) | $(XARGS) $(GOTEST) -tags="$(TEST_TAGS)" $(TEST_FLAGS)
|
UNIT := $(GOLIST) | $(XARGS) $(GOTEST) -tags="$(DEV_TAGS) $(LOG_TAGS)" $(TEST_FLAGS)
|
||||||
UNIT_RACE := $(UNIT) -race
|
UNIT_RACE := $(UNIT) -race
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
||||||
# Construct the integration test command with the added build flags.
|
# Construct the integration test command with the added build flags.
|
||||||
ITEST_TAGS := $(TEST_TAGS) rpctest
|
ITEST_TAGS := $(DEV_TAGS) rpctest
|
||||||
ITEST := rm output*.log; date; $(GOTEST) -tags="$(ITEST_TAGS)" $(TEST_FLAGS) -logoutput
|
ITEST := rm output*.log; date; $(GOTEST) -tags="$(ITEST_TAGS)" $(TEST_FLAGS) -logoutput
|
||||||
|
@ -9,16 +9,9 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/btcsuite/btcd/wire"
|
"github.com/btcsuite/btcd/wire"
|
||||||
"github.com/btcsuite/btclog"
|
|
||||||
"github.com/lightningnetwork/lnd/channeldb"
|
"github.com/lightningnetwork/lnd/channeldb"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
|
||||||
// Disable logging to prevent panics bc. of global state
|
|
||||||
channeldb.UseLogger(btclog.Disabled)
|
|
||||||
utxnLog = btclog.Disabled
|
|
||||||
}
|
|
||||||
|
|
||||||
// makeTestDB creates a new instance of the ChannelDB for testing purposes. A
|
// makeTestDB creates a new instance of the ChannelDB for testing purposes. A
|
||||||
// callback which cleans up the created temporary directories is also returned
|
// callback which cleans up the created temporary directories is also returned
|
||||||
// and intended to be executed after the test completes.
|
// and intended to be executed after the test completes.
|
||||||
|
1
peer.go
1
peer.go
@ -16,6 +16,7 @@ import (
|
|||||||
"github.com/btcsuite/btcd/txscript"
|
"github.com/btcsuite/btcd/txscript"
|
||||||
"github.com/btcsuite/btcd/wire"
|
"github.com/btcsuite/btcd/wire"
|
||||||
"github.com/davecgh/go-spew/spew"
|
"github.com/davecgh/go-spew/spew"
|
||||||
|
|
||||||
"github.com/lightningnetwork/lnd/brontide"
|
"github.com/lightningnetwork/lnd/brontide"
|
||||||
"github.com/lightningnetwork/lnd/chainntnfs"
|
"github.com/lightningnetwork/lnd/chainntnfs"
|
||||||
"github.com/lightningnetwork/lnd/channeldb"
|
"github.com/lightningnetwork/lnd/channeldb"
|
||||||
|
12
peer_test.go
12
peer_test.go
@ -7,26 +7,14 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/btcsuite/btcd/wire"
|
"github.com/btcsuite/btcd/wire"
|
||||||
"github.com/btcsuite/btclog"
|
|
||||||
"github.com/btcsuite/btcutil"
|
"github.com/btcsuite/btcutil"
|
||||||
"github.com/lightningnetwork/lnd/chainntnfs"
|
"github.com/lightningnetwork/lnd/chainntnfs"
|
||||||
"github.com/lightningnetwork/lnd/channeldb"
|
|
||||||
"github.com/lightningnetwork/lnd/contractcourt"
|
|
||||||
"github.com/lightningnetwork/lnd/htlcswitch"
|
"github.com/lightningnetwork/lnd/htlcswitch"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc"
|
"github.com/lightningnetwork/lnd/lnrpc"
|
||||||
"github.com/lightningnetwork/lnd/lnwallet"
|
"github.com/lightningnetwork/lnd/lnwallet"
|
||||||
"github.com/lightningnetwork/lnd/lnwire"
|
"github.com/lightningnetwork/lnd/lnwire"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
|
||||||
peerLog = btclog.Disabled
|
|
||||||
srvrLog = btclog.Disabled
|
|
||||||
lnwallet.UseLogger(btclog.Disabled)
|
|
||||||
htlcswitch.UseLogger(btclog.Disabled)
|
|
||||||
channeldb.UseLogger(btclog.Disabled)
|
|
||||||
contractcourt.UseLogger(btclog.Disabled)
|
|
||||||
}
|
|
||||||
|
|
||||||
// TestPeerChannelClosureAcceptFeeResponder tests the shutdown responder's
|
// TestPeerChannelClosureAcceptFeeResponder tests the shutdown responder's
|
||||||
// behavior if we can agree on the fee immediately.
|
// behavior if we can agree on the fee immediately.
|
||||||
func TestPeerChannelClosureAcceptFeeResponder(t *testing.T) {
|
func TestPeerChannelClosureAcceptFeeResponder(t *testing.T) {
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
package chainview
|
package chainview
|
||||||
|
|
||||||
import "github.com/btcsuite/btclog"
|
import (
|
||||||
|
"github.com/btcsuite/btclog"
|
||||||
|
"github.com/lightningnetwork/lnd/build"
|
||||||
|
)
|
||||||
|
|
||||||
// log is a logger that is initialized with no output filters. This
|
// log is a logger that is initialized with no output filters. This
|
||||||
// means the package will not perform any logging by default until the caller
|
// means the package will not perform any logging by default until the caller
|
||||||
@ -9,13 +12,13 @@ var log btclog.Logger
|
|||||||
|
|
||||||
// The default amount of logging is none.
|
// The default amount of logging is none.
|
||||||
func init() {
|
func init() {
|
||||||
DisableLog()
|
UseLogger(build.NewSubLogger("CRTR", nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
// DisableLog disables all library log output. Logging output is disabled
|
// DisableLog disables all library log output. Logging output is disabled
|
||||||
// by default until either UseLogger or SetLogWriter are called.
|
// by default until either UseLogger or SetLogWriter are called.
|
||||||
func DisableLog() {
|
func DisableLog() {
|
||||||
log = btclog.Disabled
|
UseLogger(btclog.Disabled)
|
||||||
}
|
}
|
||||||
|
|
||||||
// UseLogger uses a specified Logger to output package logging info.
|
// UseLogger uses a specified Logger to output package logging info.
|
||||||
|
@ -2,6 +2,7 @@ package routing
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/btcsuite/btclog"
|
"github.com/btcsuite/btclog"
|
||||||
|
"github.com/lightningnetwork/lnd/build"
|
||||||
"github.com/lightningnetwork/lnd/routing/chainview"
|
"github.com/lightningnetwork/lnd/routing/chainview"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -12,13 +13,13 @@ var log btclog.Logger
|
|||||||
|
|
||||||
// The default amount of logging is none.
|
// The default amount of logging is none.
|
||||||
func init() {
|
func init() {
|
||||||
DisableLog()
|
UseLogger(build.NewSubLogger("CRTR", nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
// DisableLog disables all library log output. Logging output is disabled by
|
// DisableLog disables all library log output. Logging output is disabled by
|
||||||
// by default until UseLogger is called.
|
// by default until UseLogger is called.
|
||||||
func DisableLog() {
|
func DisableLog() {
|
||||||
log = btclog.Disabled
|
UseLogger(btclog.Disabled)
|
||||||
}
|
}
|
||||||
|
|
||||||
// UseLogger uses a specified Logger to output package logging info. This
|
// UseLogger uses a specified Logger to output package logging info. This
|
||||||
|
@ -24,6 +24,7 @@ import (
|
|||||||
"github.com/btcsuite/btcwallet/waddrmgr"
|
"github.com/btcsuite/btcwallet/waddrmgr"
|
||||||
"github.com/coreos/bbolt"
|
"github.com/coreos/bbolt"
|
||||||
"github.com/davecgh/go-spew/spew"
|
"github.com/davecgh/go-spew/spew"
|
||||||
|
"github.com/lightningnetwork/lnd/build"
|
||||||
"github.com/lightningnetwork/lnd/channeldb"
|
"github.com/lightningnetwork/lnd/channeldb"
|
||||||
"github.com/lightningnetwork/lnd/htlcswitch"
|
"github.com/lightningnetwork/lnd/htlcswitch"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc"
|
"github.com/lightningnetwork/lnd/lnrpc"
|
||||||
@ -1190,12 +1191,12 @@ out:
|
|||||||
func (r *rpcServer) AbandonChannel(ctx context.Context,
|
func (r *rpcServer) AbandonChannel(ctx context.Context,
|
||||||
in *lnrpc.AbandonChannelRequest) (*lnrpc.AbandonChannelResponse, error) {
|
in *lnrpc.AbandonChannelRequest) (*lnrpc.AbandonChannelResponse, error) {
|
||||||
|
|
||||||
// If this isn't the debug build, then we won't allow the RPC to be
|
// If this isn't the dev build, then we won't allow the RPC to be
|
||||||
// executed, as it's an advanced feature and won't be activated in
|
// executed, as it's an advanced feature and won't be activated in
|
||||||
// regular production/release builds.
|
// regular production/release builds.
|
||||||
if !DebugBuild {
|
if !build.IsDevBuild() {
|
||||||
return nil, fmt.Errorf("AbandonChannel RPC call only " +
|
return nil, fmt.Errorf("AbandonChannel RPC call only " +
|
||||||
"available in debug builds")
|
"available in dev builds")
|
||||||
}
|
}
|
||||||
|
|
||||||
// We'll parse out the arguments to we can obtain the chanPoint of the
|
// We'll parse out the arguments to we can obtain the chanPoint of the
|
||||||
@ -1364,7 +1365,7 @@ func (r *rpcServer) GetInfo(ctx context.Context,
|
|||||||
Uris: uris,
|
Uris: uris,
|
||||||
Alias: nodeAnn.Alias.String(),
|
Alias: nodeAnn.Alias.String(),
|
||||||
BestHeaderTimestamp: int64(bestHeaderTimestamp),
|
BestHeaderTimestamp: int64(bestHeaderTimestamp),
|
||||||
Version: version(),
|
Version: build.Version(),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ func init() {
|
|||||||
// DisableLog disables all library log output. Logging output is disabled
|
// DisableLog disables all library log output. Logging output is disabled
|
||||||
// by default until UseLogger is called.
|
// by default until UseLogger is called.
|
||||||
func DisableLog() {
|
func DisableLog() {
|
||||||
log = btclog.Disabled
|
UseLogger(btclog.Disabled)
|
||||||
}
|
}
|
||||||
|
|
||||||
// UseLogger uses a specified Logger to output package logging info.
|
// UseLogger uses a specified Logger to output package logging info.
|
||||||
|
@ -13,6 +13,7 @@ import (
|
|||||||
"github.com/btcsuite/btcd/wire"
|
"github.com/btcsuite/btcd/wire"
|
||||||
"github.com/btcsuite/btcutil"
|
"github.com/btcsuite/btcutil"
|
||||||
"github.com/davecgh/go-spew/spew"
|
"github.com/davecgh/go-spew/spew"
|
||||||
|
|
||||||
"github.com/lightningnetwork/lnd/chainntnfs"
|
"github.com/lightningnetwork/lnd/chainntnfs"
|
||||||
"github.com/lightningnetwork/lnd/channeldb"
|
"github.com/lightningnetwork/lnd/channeldb"
|
||||||
"github.com/lightningnetwork/lnd/lnwallet"
|
"github.com/lightningnetwork/lnd/lnwallet"
|
||||||
|
Loading…
Reference in New Issue
Block a user