Documentation ¶
Index ¶
- Constants
- func Error(args ...interface{})
- func Errorf(format string, values ...interface{})
- func Errorw(msg string, keysAndValues ...interface{})
- func Fatalf(format string, values ...interface{})
- func GetLogServices() []string
- func InitColor(c bool)
- func InitLogger(newLogger Logger)
- func NewOCRWrapper(l Logger, trace bool, saveError func(string)) ocrtypes.Logger
- func NewORM(db *sqlx.DB, lggr Logger) *orm
- func Warn(args ...interface{})
- func Warnf(format string, values ...interface{})
- func Warnw(msg string, keysAndValues ...interface{})
- type Config
- type Fields
- type LogConfig
- type Logger
- type MemorySink
- type ORM
- type PrettyConsole
- type T
Constants ¶
const ( HeadTracker = "head_tracker" FluxMonitor = "fluxmonitor" Keeper = "keeper" )
Constants for service names for package specific logging configuration
const SentryFlushDeadline = 5 * time.Second
Variables ¶
This section is empty.
Functions ¶
func Errorf ¶
func Errorf(format string, values ...interface{})
Errorf logs a message at the error level using Sprintf. Deprecated
func Errorw ¶
func Errorw(msg string, keysAndValues ...interface{})
Errorw logs an error message, any additional given information, and includes stack trace. Deprecated
func Fatalf ¶
func Fatalf(format string, values ...interface{})
Fatalf logs a message at the fatal level using Sprintf. Deprecated
func GetLogServices ¶ added in v0.10.6
func GetLogServices() []string
func InitColor ¶ added in v1.1.0
func InitColor(c bool)
InitColor explicitly sets the global color.NoColor option. Not safe for concurrent use. Only to be called from init().
func InitLogger ¶ added in v1.1.0
func InitLogger(newLogger Logger)
InitLogger sets the helper Logger to newLogger. Not safe for concurrent use, so must be called from init() or the main goroutine during initialization.
You probably don't want to use this. Loggers should be injected instead. Deprecated
func NewOCRWrapper ¶ added in v1.1.0
Types ¶
type LogConfig ¶ added in v0.10.6
type LogConfig struct { ID int64 ServiceName string LogLevel string CreatedAt time.Time UpdatedAt time.Time }
LogConfig stores key value pairs for configuring package specific logging
type Logger ¶
type Logger interface { // With creates a new Logger with the given arguments With(args ...interface{}) Logger // Named creates a new Logger sub-scoped with name. // Names are inherited and dot-separated. // a := l.Named("a") // logger=a // b := a.Named("b") // logger=a.b Named(name string) Logger // NewRootLogger creates a new root Logger with an independent log level // unaffected by upstream calls to SetLogLevel. NewRootLogger(lvl zapcore.Level) (Logger, error) // SetLogLevel changes the log level for this and all connected Loggers. SetLogLevel(zapcore.Level) Trace(args ...interface{}) Debug(args ...interface{}) Info(args ...interface{}) Warn(args ...interface{}) Error(args ...interface{}) Critical(args ...interface{}) Panic(args ...interface{}) Fatal(args ...interface{}) Tracef(format string, values ...interface{}) Debugf(format string, values ...interface{}) Infof(format string, values ...interface{}) Warnf(format string, values ...interface{}) Errorf(format string, values ...interface{}) Criticalf(format string, values ...interface{}) Panicf(format string, values ...interface{}) Fatalf(format string, values ...interface{}) Tracew(msg string, keysAndValues ...interface{}) Debugw(msg string, keysAndValues ...interface{}) Infow(msg string, keysAndValues ...interface{}) Warnw(msg string, keysAndValues ...interface{}) Errorw(msg string, keysAndValues ...interface{}) CriticalW(msg string, keysAndValues ...interface{}) Panicw(msg string, keysAndValues ...interface{}) Fatalw(msg string, keysAndValues ...interface{}) // ErrorIf logs the error if present. ErrorIf(err error, msg string) // ErrorIfClosing calls c.Close() and logs any returned error along with name. ErrorIfClosing(c io.Closer, name string) // Sync flushes any buffered log entries. // Some insignificant errors are suppressed. Sync() error // Helper creates a new logger with the number of callers skipped by caller annotation increased by skip. // This allows wrappers and helpers to point higher up the stack (like testing.T.Helper()). Helper(skip int) Logger }
var NullLogger Logger
func NewLogger ¶ added in v1.1.0
NewLogger returns a new Logger configured by c with pretty printing to stdout. If LogToDisk is false, the Logger will only log to stdout. Tests should use TestLogger instead.
func NewNullLogger ¶ added in v1.1.0
func NewNullLogger() Logger
func TestLogger ¶ added in v1.1.0
TestLogger creates a logger that directs output to PrettyConsole configured for test output, and to the buffer testMemoryLog. t is optional. Log level is derived from the LOG_LEVEL env var.
type MemorySink ¶ added in v0.8.15
type MemorySink struct {
// contains filtered or unexported fields
}
MemorySink implements zap.Sink by writing all messages to a buffer.
func MemoryLogTestingOnly ¶ added in v0.8.15
func MemoryLogTestingOnly() *MemorySink
func (*MemorySink) Close ¶ added in v0.8.15
func (s *MemorySink) Close() error
Close is a dummy method to satisfy the zap.Sink interface
func (*MemorySink) Reset ¶ added in v1.1.0
func (s *MemorySink) Reset()
func (*MemorySink) String ¶ added in v0.8.15
func (s *MemorySink) String() string
String returns the full log contents, as a string
func (*MemorySink) Sync ¶ added in v0.8.15
func (s *MemorySink) Sync() error
Sync is a dummy method to satisfy the zap.Sink interface
type PrettyConsole ¶
PrettyConsole wraps a Sink (Writer, Syncer, Closer), usually stdout, and formats the incoming json bytes with colors and white space for readability before passing on to the underlying Writer in Sink.