{"modulePath":"github.com/chainopen/ethchaincode","version":"v0.0.0-20190924072703-d975acdaa1c6","isLatest":true,"isStandardLibrary":false,"goos":"linux","goarch":"amd64","docs":"# package log\n\nPackage log15 provides an opinionated, simple toolkit for best-practice logging that is both human and machine readable. It is modeled after the standard library's io and net/http packages.\n\nThis package enforces you to only log key/value pairs. Keys must be strings. Values may be any type that you like. The default output format is logfmt, but you may also choose to use JSON instead if that suits you. Here's how you log:\n\n\tlog.Info(\"page accessed\", \"path\", r.URL.Path, \"user_id\", user.id)\n\nThis will output a line that looks like:\n\n\tlvl=info t=2014-05-02T16:07:23-0700 msg=\"page accessed\" path=/org/71/profile user_id=9\n\n### Getting Started {#hdr-Getting_Started}\n\nTo get started, you'll want to import the library:\n\n\timport log \"github.com/inconshreveable/log15\"\n\nNow you're ready to start logging:\n\n\tfunc main() {\n\t    log.Info(\"Program starting\", \"args\", os.Args())\n\t}\n\n### Convention {#hdr-Convention}\n\nBecause recording a human-meaningful message is common and good practice, the first argument to every logging method is the value to the \\*implicit\\* key 'msg'.\n\nAdditionally, the level you choose for a message will be automatically added with the key 'lvl', and so will the current timestamp with key 't'.\n\nYou may supply any additional context as a set of key/value pairs to the logging function. log15 allows you to favor terseness, ordering, and speed over safety. This is a reasonable tradeoff for logging functions. You don't need to explicitly state keys/values, log15 understands that they alternate in the variadic argument list:\n\n\tlog.Warn(\"size out of bounds\", \"low\", lowBound, \"high\", highBound, \"val\", val)\n\nIf you really do favor your type-safety, you may choose to pass a log.Ctx instead:\n\n\tlog.Warn(\"size out of bounds\", log.Ctx{\"low\": lowBound, \"high\": highBound, \"val\": val})\n\n### Context loggers {#hdr-Context_loggers}\n\nFrequently, you want to add context to a logger so that you can track actions associated with it. An http request is a good example. You can easily create new loggers that have context that is automatically included with each log line:\n\n\trequestlogger := log.New(\"path\", r.URL.Path)\n\n\t// later\n\trequestlogger.Debug(\"db txn commit\", \"duration\", txnTimer.Finish())\n\nThis will output a log line that includes the path context that is attached to the logger:\n\n\tlvl=dbug t=2014-05-02T16:07:23-0700 path=/repo/12/add_hook msg=\"db txn commit\" duration=0.12\n\n### Handlers {#hdr-Handlers}\n\nThe Handler interface defines where log lines are printed to and how they are formated. Handler is a single interface that is inspired by net/http's handler interface:\n\n\ttype Handler interface {\n\t    Log(r *Record) error\n\t}\n\nHandlers can filter records, format them, or dispatch to multiple other Handlers. This package implements a number of Handlers for common logging patterns that are easily composed to create flexible, custom logging structures.\n\nHere's an example handler that prints logfmt output to Stdout:\n\n\thandler := log.StreamHandler(os.Stdout, log.LogfmtFormat())\n\nHere's an example handler that defers to two other handlers. One handler only prints records from the rpc package in logfmt to standard out. The other prints records at Error level or above in JSON formatted output to the file /var/log/service.json\n\n\thandler := log.MultiHandler(\n\t    log.LvlFilterHandler(log.LvlError, log.Must.FileHandler(\"/var/log/service.json\", log.JSONFormat())),\n\t    log.MatchFilterHandler(\"pkg\", \"app/rpc\" log.StdoutHandler())\n\t)\n\n### Logging File Names and Line Numbers {#hdr-Logging_File_Names_and_Line_Numbers}\n\nThis package implements three Handlers that add debugging information to the context, CallerFileHandler, CallerFuncHandler and CallerStackHandler. Here's an example that adds the source file and line number of each logging call to the context.\n\n\th := log.CallerFileHandler(log.StdoutHandler)\n\tlog.Root().SetHandler(h)\n\t...\n\tlog.Error(\"open file\", \"err\", err)\n\nThis will output a line that looks like:\n\n\tlvl=eror t=2014-05-02T16:07:23-0700 msg=\"open file\" err=\"file not found\" caller=data.go:42\n\nHere's an example that logs the call stack rather than just the call site.\n\n\th := log.CallerStackHandler(\"%+v\", log.StdoutHandler)\n\tlog.Root().SetHandler(h)\n\t...\n\tlog.Error(\"open file\", \"err\", err)\n\nThis will output a line that looks like:\n\n\tlvl=eror t=2014-05-02T16:07:23-0700 msg=\"open file\" err=\"file not found\" stack=\"[pkg/data.go:42 pkg/cmd/main.go]\"\n\nThe \"%+v\" format instructs the handler to include the path of the source file relative to the compile time GOPATH. The github.com/go-stack/stack package documents the full list of formatting verbs and modifiers available.\n\n### Custom Handlers {#hdr-Custom_Handlers}\n\nThe Handler interface is so simple that it's also trivial to write your own. Let's create an example handler which tries to write to one handler, but if that fails it falls back to writing to another handler and includes the error that it encountered when trying to write to the primary. This might be useful when trying to log over a network socket, but if that fails you want to log those records to a file on disk.\n\n\ttype BackupHandler struct {\n\t    Primary Handler\n\t    Secondary Handler\n\t}\n\n\tfunc (h *BackupHandler) Log (r *Record) error {\n\t    err := h.Primary.Log(r)\n\t    if err != nil {\n\t        r.Ctx = append(ctx, \"primary_err\", err)\n\t        return h.Secondary.Log(r)\n\t    }\n\t    return nil\n\t}\n\nThis pattern is so useful that a generic version that handles an arbitrary number of Handlers is included as part of this library called FailoverHandler.\n\n### Logging Expensive Operations {#hdr-Logging_Expensive_Operations}\n\nSometimes, you want to log values that are extremely expensive to compute, but you don't want to pay the price of computing them if you haven't turned up your logging level to a high level of detail.\n\nThis package provides a simple type to annotate a logging operation that you want to be evaluated lazily, just when it is about to be logged, so that it would not be evaluated if an upstream Handler filters it out. Just wrap any function which takes no arguments with the log.Lazy type. For example:\n\n\tfunc factorRSAKey() (factors []int) {\n\t    // return the factors of a very large number\n\t}\n\n\tlog.Debug(\"factors\", log.Lazy{factorRSAKey})\n\nIf this message is not logged for any reason (like logging at the Error level), then factorRSAKey is never evaluated.\n\n### Dynamic context values {#hdr-Dynamic_context_values}\n\nThe same log.Lazy mechanism can be used to attach context to a logger which you want to be evaluated when the message is logged, but not when the logger is created. For example, let's imagine a game where you have Player objects:\n\n\ttype Player struct {\n\t    name string\n\t    alive bool\n\t    log.Logger\n\t}\n\nYou always want to log a player's name and whether they're alive or dead, so when you create the player object, you might do:\n\n\tp := \u0026Player{name: name, alive: true}\n\tp.Logger = log.New(\"name\", p.name, \"alive\", p.alive)\n\nOnly now, even after a player has died, the logger will still report they are alive because the logging context is evaluated when the logger was created. By using the Lazy wrapper, we can defer the evaluation of whether the player is alive or not to each log message, so that the log records will reflect the player's current state no matter when the log message is written:\n\n\tp := \u0026Player{name: name, alive: true}\n\tisAlive := func() bool { return p.alive }\n\tplayer.Logger = log.New(\"name\", p.name, \"alive\", log.Lazy{isAlive})\n\n### Terminal Format {#hdr-Terminal_Format}\n\nIf log15 detects that stdout is a terminal, it will configure the default handler for it (which is log.StdoutHandler) to use TerminalFormat. This format logs records nicely for your terminal, including color-coded output based on log level.\n\n### Error Handling {#hdr-Error_Handling}\n\nBecasuse log15 allows you to step around the type system, there are a few ways you can specify invalid arguments to the logging functions. You could, for example, wrap something that is not a zero-argument function with log.Lazy or pass a context key that is not a string. Since logging libraries are typically the mechanism by which errors are reported, it would be onerous for the logging functions to return errors. Instead, log15 handles errors by making these guarantees to you:\n\n\\- Any log record containing an error will still be printed with the error explained to you as part of the log record.\n\n\\- Any log record containing an error will include the context key LOG15\\_ERROR, enabling you to easily (and if you like, automatically) detect if any of your logging calls are passing bad values.\n\nUnderstanding this, you might wonder why the Handler interface can return an error value in its Log method. Handlers are encouraged to return errors only if they fail to write their log records out to an external source like if the syslog daemon is not responding. This allows the construction of useful handlers which cope with those failures like the FailoverHandler.\n\n### Library Use {#hdr-Library_Use}\n\nlog15 is intended to be useful for library authors as a way to provide configurable logging to users of their library. Best practice for use in a library is to always disable all output for your logger by default and to provide a public Logger instance that consumers of your library can configure. Like so:\n\n\tpackage yourlib\n\n\timport \"github.com/inconshreveable/log15\"\n\n\tvar Log = log.New()\n\n\tfunc init() {\n\t    Log.SetHandler(log.DiscardHandler())\n\t}\n\nUsers of your library may then enable it if they like:\n\n\timport \"github.com/inconshreveable/log15\"\n\timport \"example.com/yourlib\"\n\n\tfunc main() {\n\t    handler := // custom handler setup\n\t    yourlib.Log.SetHandler(handler)\n\t}\n\n### Best practices attaching logger context {#hdr-Best_practices_attaching_logger_context}\n\nThe ability to attach context to a logger is a powerful one. Where should you do it and why? I favor embedding a Logger directly into any persistent object in my application and adding unique, tracing context keys to it. For instance, imagine I am writing a web browser:\n\n\ttype Tab struct {\n\t    url string\n\t    render *RenderingContext\n\t    // ...\n\n\t    Logger\n\t}\n\n\tfunc NewTab(url string) *Tab {\n\t    return \u0026Tab {\n\t        // ...\n\t        url: url,\n\n\t        Logger: log.New(\"url\", url),\n\t    }\n\t}\n\nWhen a new tab is created, I assign a logger to it with the url of the tab as context so it can easily be traced through the logs. Now, whenever we perform any operation with the tab, we'll log with its embedded logger and it will include the tab title automatically:\n\n\ttab.Debug(\"moved position\", \"idx\", tab.idx)\n\nThere's only one problem. What if the tab url changes? We could use log.Lazy to make sure the current url is always written, but that would mean that we couldn't trace a tab's full lifetime through our logs after the user navigate to a new URL.\n\nInstead, think about what values to attach to your loggers the same way you think about what to use as a key in a SQL database schema. If it's possible to use a natural key that is unique for the lifetime of the object, do so. But otherwise, log15's ext package has a handy RandId function to let you generate what you might call \"surrogate keys\" They're just random hex identifiers to use for tracing. Back to our Tab example, we would prefer to set up our Logger like so:\n\n\timport logext \"github.com/inconshreveable/log15/ext\"\n\n\tt := \u0026Tab {\n\t    // ...\n\t    url: url,\n\t}\n\n\tt.Logger = log.New(\"id\", logext.RandId(8), \"url\", log.Lazy{t.getUrl})\n\treturn t\n\nNow we'll have a unique traceable identifier even across loading new urls, but we'll still be able to see the tab's current url in the log messages.\n\n### Must {#hdr-Must}\n\nFor all Handler functions which can return an error, there is a version of that function which will return no error but panics on failure. They are all available on the Must object. For example:\n\n\tlog.Must.FileHandler(\"/path\", log.JSONFormat)\n\tlog.Must.NetHandler(\"tcp\", \":1234\", log.JSONFormat)\n\n### Inspiration and Credit {#hdr-Inspiration_and_Credit}\n\nAll of the following excellent projects inspired the design of this library:\n\ncode.google.com/p/log4go\n\ngithub.com/op/go-logging\n\ngithub.com/technoweenie/grohl\n\ngithub.com/Sirupsen/logrus\n\ngithub.com/kr/logfmt\n\ngithub.com/spacemonkeygo/spacelog\n\ngolang's stdlib, notably io and net/http\n\n### The Name {#hdr-The_Name}\n\n[https://xkcd.com/927/](https://xkcd.com/927/)\n\n## Variables\n\n```go\nvar (\n\tStdoutHandler = StreamHandler(os.Stdout, LogfmtFormat())\n\tStderrHandler = StreamHandler(os.Stderr, LogfmtFormat())\n)\n```\n\n```go\nvar Must muster\n```\nMust provides the following Handler creation functions which instead of returning an error parameter only return a Handler and panic on failure: FileHandler, NetHandler, SyslogHandler, SyslogNetHandler\n\n## Functions\n\n```go\nfunc Crit(msg string, ctx ...interface{})\n```\nCrit is a convenient alias for Root().Crit\n\n```go\nfunc Debug(msg string, ctx ...interface{})\n```\nDebug is a convenient alias for Root().Debug\n\n```go\nfunc Error(msg string, ctx ...interface{})\n```\nError is a convenient alias for Root().Error\n\n```go\nfunc Info(msg string, ctx ...interface{})\n```\nInfo is a convenient alias for Root().Info\n\n```go\nfunc Output(msg string, lvl Lvl, calldepth int, ctx ...interface{})\n```\nOutput is a convenient alias for write, allowing for the modification of the calldepth (number of stack frames to skip). calldepth influences the reported line number of the log message. A calldepth of zero reports the immediate caller of Output. Non-zero calldepth skips as many stack frames.\n\n```go\nfunc PrintOrigins(print bool)\n```\nPrintOrigins sets or unsets log location (file:line) printing for terminal format output.\n\n```go\nfunc Trace(msg string, ctx ...interface{})\n```\nTrace is a convenient alias for Root().Trace\n\n```go\nfunc Warn(msg string, ctx ...interface{})\n```\nWarn is a convenient alias for Root().Warn\n\n## Types\n\n```go\ntype Ctx map[string]interface{}\n```\nCtx is a map of key/value pairs to pass as context to a log function Use this only if you really need greater safety around the arguments you pass to the logging functions.\n\n```go\ntype Format interface {\n\tFormat(r *Record) []byte\n}\n```\n\n```go\nfunc FormatFunc(f func(*Record) []byte) Format\n```\nFormatFunc returns a new Format object which uses the given function to perform record formatting.\n\n```go\nfunc JSONFormat() Format\n```\nJSONFormat formats log records as JSON objects separated by newlines. It is the equivalent of JSONFormatEx(false, true).\n\n```go\nfunc JSONFormatEx(pretty, lineSeparated bool) Format\n```\nJSONFormatEx formats log records as JSON objects. If pretty is true, records will be pretty-printed. If lineSeparated is true, records will be logged with a new line between each record.\n\n```go\nfunc JSONFormatOrderedEx(pretty, lineSeparated bool) Format\n```\nJSONFormatOrderedEx formats log records as JSON arrays. If pretty is true, records will be pretty-printed. If lineSeparated is true, records will be logged with a new line between each record.\n\n```go\nfunc LogfmtFormat() Format\n```\nLogfmtFormat prints records in logfmt format, an easy machine-parseable but human-readable format for key/value pairs.\n\nFor more details see: [http://godoc.org/github.com/kr/logfmt](http://godoc.org/github.com/kr/logfmt)\n\n```go\nfunc TerminalFormat(usecolor bool) Format\n```\nTerminalFormat formats log records optimized for human readability on a terminal with color-coded level output and terser human friendly timestamp. This format should only be used for interactive programs or while developing.\n\n\t[LEVEL] [TIME] MESAGE key=value key=value ...\n\nExample:\n\n\t[DBUG] [May 16 20:58:45] remove route ns=haproxy addr=127.0.0.1:50002\n\n```go\ntype GlogHandler struct {\n\t// contains filtered or unexported fields\n}\n```\nGlogHandler is a log handler that mimics the filtering features of Google's glog logger: setting global log levels; overriding with callsite pattern matches; and requesting backtraces at certain positions.\n\n```go\nfunc NewGlogHandler(h Handler) *GlogHandler\n```\nNewGlogHandler creates a new log handler with filtering functionality similar to Google's glog logger. The returned handler implements Handler.\n\n```go\nfunc (h *GlogHandler) BacktraceAt(location string) error\n```\nBacktraceAt sets the glog backtrace location. When set to a file and line number holding a logging statement, a stack trace will be written to the Info log whenever execution hits that statement.\n\nUnlike with Vmodule, the \".go\" must be present.\n\n```go\nfunc (h *GlogHandler) Log(r *Record) error\n```\nLog implements Handler.Log, filtering a log record through the global, local and backtrace filters, finally emitting it if either allow it through.\n\n```go\nfunc (h *GlogHandler) SetHandler(nh Handler)\n```\nSetHandler updates the handler to write records to the specified sub-handler.\n\n```go\nfunc (h *GlogHandler) Verbosity(level Lvl)\n```\nVerbosity sets the glog verbosity ceiling. The verbosity of individual packages and source files can be raised using Vmodule.\n\n```go\nfunc (h *GlogHandler) Vmodule(ruleset string) error\n```\nVmodule sets the glog verbosity pattern.\n\nThe syntax of the argument is a comma-separated list of pattern=N, where the pattern is a literal file name or \"glob\" pattern matching and N is a V level.\n\nFor instance:\n\n\tpattern=\"gopher.go=3\"\n\t sets the V level to 3 in all Go files named \"gopher.go\"\n\n\tpattern=\"foo=3\"\n\t sets V to 3 in all files of any packages whose import path ends in \"foo\"\n\n\tpattern=\"foo/*=3\"\n\t sets V to 3 in all files of any packages whose import path contains \"foo\"\n\n```go\ntype Handler interface {\n\tLog(r *Record) error\n}\n```\nHandler defines where and how log records are written. A Logger prints its log records by writing to a Handler. Handlers are composable, providing you great flexibility in combining them to achieve the logging structure that suits your applications.\n\n```go\nfunc BufferedHandler(bufSize int, h Handler) Handler\n```\nBufferedHandler writes all records to a buffered channel of the given size which flushes into the wrapped handler whenever it is available for writing. Since these writes happen asynchronously, all writes to a BufferedHandler never return an error and any errors from the wrapped handler are ignored.\n\n```go\nfunc CallerFileHandler(h Handler) Handler\n```\nCallerFileHandler returns a Handler that adds the line number and file of the calling function to the context with key \"caller\".\n\n```go\nfunc CallerFuncHandler(h Handler) Handler\n```\nCallerFuncHandler returns a Handler that adds the calling function name to the context with key \"fn\".\n\n```go\nfunc CallerStackHandler(format string, h Handler) Handler\n```\nCallerStackHandler returns a Handler that adds a stack trace to the context with key \"stack\". The stack trace is formated as a space separated list of call sites inside matching \\[]'s. The most recent call site is listed first. Each call site is formatted according to format. See the documentation of package github.com/go-stack/stack for the list of supported formats.\n\n```go\nfunc ChannelHandler(recs chan\u003c- *Record) Handler\n```\nChannelHandler writes all records to the given channel. It blocks if the channel is full. Useful for async processing of log messages, it's used by BufferedHandler.\n\n```go\nfunc DiscardHandler() Handler\n```\nDiscardHandler reports success for all writes but does nothing. It is useful for dynamically disabling logging at runtime via a Logger's SetHandler method.\n\n```go\nfunc FailoverHandler(hs ...Handler) Handler\n```\nFailoverHandler writes all log records to the first handler specified, but will failover and write to the second handler if the first handler has failed, and so on for all handlers specified. For example you might want to log to a network socket, but failover to writing to a file if the network fails, and then to standard out if the file write fails:\n\n\tlog.FailoverHandler(\n\t    log.Must.NetHandler(\"tcp\", \":9090\", log.JSONFormat()),\n\t    log.Must.FileHandler(\"/var/log/app.log\", log.LogfmtFormat()),\n\t    log.StdoutHandler)\n\nAll writes that do not go to the first handler will add context with keys of the form \"failover\\_err\\_{idx}\" which explain the error encountered while trying to write to the handlers before them in the list.\n\n```go\nfunc FileHandler(path string, fmtr Format) (Handler, error)\n```\nFileHandler returns a handler which writes log records to the give file using the given format. If the path already exists, FileHandler will append to the given file. If it does not, FileHandler will create the file with mode 0644.\n\n```go\nfunc FilterHandler(fn func(r *Record) bool, h Handler) Handler\n```\nFilterHandler returns a Handler that only writes records to the wrapped Handler if the given function evaluates true. For example, to only log records where the 'err' key is not nil:\n\n\tlogger.SetHandler(FilterHandler(func(r *Record) bool {\n\t    for i := 0; i \u003c len(r.Ctx); i += 2 {\n\t        if r.Ctx[i] == \"err\" {\n\t            return r.Ctx[i+1] != nil\n\t        }\n\t    }\n\t    return false\n\t}, h))\n\n```go\nfunc FuncHandler(fn func(r *Record) error) Handler\n```\nFuncHandler returns a Handler that logs records with the given function.\n\n```go\nfunc LazyHandler(h Handler) Handler\n```\nLazyHandler writes all values to the wrapped handler after evaluating any lazy functions in the record's context. It is already wrapped around StreamHandler and SyslogHandler in this library, you'll only need it if you write your own Handler.\n\n```go\nfunc LvlFilterHandler(maxLvl Lvl, h Handler) Handler\n```\nLvlFilterHandler returns a Handler that only writes records which are less than the given verbosity level to the wrapped Handler. For example, to only log Error/Crit records:\n\n\tlog.LvlFilterHandler(log.LvlError, log.StdoutHandler)\n\n```go\nfunc MatchFilterHandler(key string, value interface{}, h Handler) Handler\n```\nMatchFilterHandler returns a Handler that only writes records to the wrapped Handler if the given key in the logged context matches the value. For example, to only log records from your ui package:\n\n\tlog.MatchFilterHandler(\"pkg\", \"app/ui\", log.StdoutHandler)\n\n```go\nfunc MultiHandler(hs ...Handler) Handler\n```\nMultiHandler dispatches any write to each of its handlers. This is useful for writing different types of log information to different locations. For example, to log to a file and standard error:\n\n\tlog.MultiHandler(\n\t    log.Must.FileHandler(\"/var/log/app.log\", log.LogfmtFormat()),\n\t    log.StderrHandler)\n\n```go\nfunc NetHandler(network, addr string, fmtr Format) (Handler, error)\n```\nNetHandler opens a socket to the given address and writes records over the connection.\n\n```go\nfunc RotatingFileHandler(path string, limit uint, formatter Format) (Handler, error)\n```\nRotatingFileHandler returns a handler which writes log records to file chunks at the given path. When a file's size reaches the limit, the handler creates a new file named after the timestamp of the first log record it will contain.\n\n```go\nfunc StreamHandler(wr io.Writer, fmtr Format) Handler\n```\nStreamHandler writes log records to an io.Writer with the given format. StreamHandler can be used to easily begin writing log records to other outputs.\n\nStreamHandler wraps itself with LazyHandler and SyncHandler to evaluate Lazy objects and perform safe concurrent writes.\n\n```go\nfunc SyncHandler(h Handler) Handler\n```\nSyncHandler can be wrapped around a handler to guarantee that only a single Log operation can proceed at a time. It's necessary for thread-safe concurrent writes.\n\n```go\nfunc SyslogHandler(priority syslog.Priority, tag string, fmtr Format) (Handler, error)\n```\nSyslogHandler opens a connection to the system syslog daemon by calling syslog.New and writes all records to it.\n\n```go\nfunc SyslogNetHandler(net, addr string, priority syslog.Priority, tag string, fmtr Format) (Handler, error)\n```\nSyslogNetHandler opens a connection to a log daemon over the network and writes all log records to it.\n\n```go\ntype Lazy struct {\n\tFn interface{}\n}\n```\nLazy allows you to defer calculation of a logged value that is expensive to compute until it is certain that it must be evaluated with the given filters.\n\nLazy may also be used in conjunction with a Logger's New() function to generate a child logger which always reports the current value of changing state.\n\nYou may wrap any function which takes no arguments to Lazy. It may return any number of values of any type.\n\n```go\ntype Logger interface {\n\t// New returns a new Logger that has this logger's context plus the given context\n\tNew(ctx ...interface{}) Logger\n\n\t// GetHandler gets the handler associated with the logger.\n\tGetHandler() Handler\n\n\t// SetHandler updates the logger to write records to the specified handler.\n\tSetHandler(h Handler)\n\n\t// Log a message at the given level with context key/value pairs\n\tTrace(msg string, ctx ...interface{})\n\tDebug(msg string, ctx ...interface{})\n\tInfo(msg string, ctx ...interface{})\n\tWarn(msg string, ctx ...interface{})\n\tError(msg string, ctx ...interface{})\n\tCrit(msg string, ctx ...interface{})\n}\n```\nA Logger writes key/value pairs to a Handler\n\n```go\nfunc New(ctx ...interface{}) Logger\n```\nNew returns a new logger with the given context. New is a convenient alias for Root().New\n\n```go\nfunc Root() Logger\n```\nRoot returns the root logger\n\n```go\ntype Lvl int\n```\n\n```go\nconst (\n\tLvlCrit Lvl = iota\n\tLvlError\n\tLvlWarn\n\tLvlInfo\n\tLvlDebug\n\tLvlTrace\n)\n```\n\n```go\nfunc LvlFromString(lvlString string) (Lvl, error)\n```\nLvlFromString returns the appropriate Lvl from a string name. Useful for parsing command line args and configuration files.\n\n```go\nfunc (l Lvl) AlignedString() string\n```\nAlignedString returns a 5-character string containing the name of a Lvl.\n\n```go\nfunc (l Lvl) String() string\n```\nStrings returns the name of a Lvl.\n\n```go\ntype Record struct {\n\tTime     time.Time\n\tLvl      Lvl\n\tMsg      string\n\tCtx      []interface{}\n\tCall     stack.Call\n\tKeyNames RecordKeyNames\n}\n```\nA Record is what a Logger asks its handler to write\n\n```go\ntype RecordKeyNames struct {\n\tTime string\n\tMsg  string\n\tLvl  string\n\tCtx  string\n}\n```\nRecordKeyNames gets stored in a Record when the write function is executed.\n\n```go\ntype TerminalStringer interface {\n\tTerminalString() string\n}\n```\nTerminalStringer is an analogous interface to the stdlib stringer, allowing own types to have custom shortened serialization formats when printed to the screen.\n\n","path":"github.com/chainopen/ethchaincode/log","name":"log","synopsis":"Package log15 provides an opinionated, simple toolkit for best-practice logging that is both human and machine readable.","isRedistributable":true}
