status-go/geth/log
Alex Kohler 228bda9fb3 Remove //nolint: gas directives from fmt.Fprintf #590 (#656)
Summary:
Filter out gas linter error checks for fmt.Fprintf commands. This required defining a custom linter around gas that additionally included the offending code.

Notes:

Gas format, without piping it through gometalinter, gives output like this:

$ gas -fmt=csv geth/jail/console/console.go
geth/jail/console/console.go,21,Errors unhandled.,LOW,HIGH,"fmt.Fprintf(w, ""%s: %s"", consoleEventName, formatForConsole(fn.ArgumentList))"
Gometalinter, by default, does not grab the line of code when it filters gas errors. To resolve this, I created a wrapper around gas (I wasn't sure what to call this "gas wrapper", I opted for gasv2, open to other names).

The first part of the regular expression was taken directly from gometalinter (see https://github.com/alecthomas/gometalinter/blob/master/linters.go#L236), and I then appended ,\".*\" to additionally grab the line of code of the offending line. Lastly, I excluded ".*Errors unhandled.*fmt.Fprintf.*" to filter out only fmt.Fprintf errors around omitted errors.

Also as a result of this change, gas lint output will now include the offending code.

Closes #590
2018-02-14 19:58:20 +02:00
..
README.md Add some docs/readmes (#329) 2017-09-15 19:00:00 +03:00
log.go Remove //nolint: gas directives from fmt.Fprintf #590 (#656) 2018-02-14 19:58:20 +02:00
log_test.go Fix make lint warnings (#417) 2017-10-20 12:06:22 +03:00

README.md

log GoDoc

Package log implements logger for status-go.

Download:

go get github.com/status-im/status-go/geth/log

Package log implements logger for status-go.

This logger handles two loggers - it's own and ethereum-go logger. Both are used as "singletons" - using global shared variables.

Usage

First, import package into your code:

import "github.com/status-im/status-go/geth/log

Then simply use Info/Error/Debug/etc functions to log at desired level:

log.Info("Info message")
log.Debug("Debug message")
log.Error("Error message")

Slightly more complicated logging:

log.Warn("abnormal conn rate", "rate", curRate, "low", lowRate, "high", highRate)

Note, in this case parameters should be in in pairs (key, value).

This logger is based upon log15-logger, so see its documentation for advanced usage: https://github.com/inconshreveable/log15

Initialization

By default logger is set to log to stdout with Error level via init() function. You may change both level and file output by log.SetLevel() and log.SetLogFile() functions:

log.SetLevel("DEBUG")
log.SetLogFile("/path/to/geth.log")

Automatically generated by autoreadme on 2017.09.15