logging

package
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 16, 2017 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package logging handles logging throughout Atlantis.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LogLevel

type LogLevel int
const (
	Debug LogLevel = iota
	Info
	Warn
	Error
)

func ToLogLevel

func ToLogLevel(levelStr string) LogLevel

ToLogLevel converts a log level string to a valid LogLevel object. If the string doesn't match a level, it will return Info.

type SimpleLogger

type SimpleLogger struct {
	// Source is added as a prefix to each log entry.
	// It's useful if you want to trace a log entry back to a
	// context, for example a pull request id.
	Source string
	// History stores all log entries ever written using
	// this logger. This is safe for short-lived loggers
	// like those used during plan/apply commands.
	History     bytes.Buffer
	Logger      *log.Logger
	KeepHistory bool
	Level       LogLevel
}

SimpleLogger wraps the standard logger with leveled logging and the ability to store log history for later adding it to a GitHub comment.

func NewNoopLogger

func NewNoopLogger() *SimpleLogger

NewNoopLogger creates a logger instance that discards all logs and never writes them. Used for testing.

func NewSimpleLogger

func NewSimpleLogger(source string, logger *log.Logger, keepHistory bool, level LogLevel) *SimpleLogger

NewSimpleLogger creates a new logger.

  • source is added as a prefix to each log entry. It's useful if you want to trace a log entry back to a context, for example a pull request id.
  • logger is the underlying logger. If nil will create a logger from stdlib.
  • keepHistory set to true will store all log entries written using this logger.
  • level will set the level at which logs >= than that level will be written. If keepHistory is set to true, we'll store logs at all levels, regardless of what level is set to.

func (*SimpleLogger) Debug

func (l *SimpleLogger) Debug(format string, a ...interface{})

func (*SimpleLogger) Err

func (l *SimpleLogger) Err(format string, a ...interface{})

func (*SimpleLogger) Info

func (l *SimpleLogger) Info(format string, a ...interface{})

func (*SimpleLogger) Log

func (l *SimpleLogger) Log(level LogLevel, format string, a ...interface{})

func (*SimpleLogger) Warn

func (l *SimpleLogger) Warn(format string, a ...interface{})

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL