logging

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2019 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Copyright 2017 HootSuite Media Inc.

Licensed under the Apache License, Version 2.0 (the License); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Modified hereafter by contributors to runatlantis/atlantis.

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
)

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 VCS 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, 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 specific context, for example a pull request id. 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{})

Debug logs at debug level.

func (*SimpleLogger) Err

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

Err logs at error level.

func (*SimpleLogger) GetLevel added in v0.2.0

func (l *SimpleLogger) GetLevel() LogLevel

GetLevel returns the current log level of the logger.

func (*SimpleLogger) Info

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

Info logs at info level.

func (*SimpleLogger) Log

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

Log writes the log at level.

func (*SimpleLogger) NewLogger added in v0.4.13

func (l *SimpleLogger) NewLogger(source string, keepHistory bool, lvl LogLevel) *SimpleLogger

NewLogger returns a new logger that reuses the underlying logger.

func (*SimpleLogger) SetLevel added in v0.4.13

func (l *SimpleLogger) SetLevel(lvl LogLevel)

SetLevel changes the level that this logger is writing at to lvl.

func (*SimpleLogger) Underlying added in v0.2.0

func (l *SimpleLogger) Underlying() *log.Logger

Underlying returns the underlying logger.

func (*SimpleLogger) Warn

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

Warn logs at warn level.

type SimpleLogging added in v0.2.0

type SimpleLogging interface {
	Debug(format string, a ...interface{})
	Info(format string, a ...interface{})
	Warn(format string, a ...interface{})
	Err(format string, a ...interface{})
	Log(level LogLevel, format string, a ...interface{})
	// Underlying returns the underlying logger.
	Underlying() *log.Logger
	// GetLevel returns the current log level.
	GetLevel() LogLevel
	NewLogger(string, bool, LogLevel) *SimpleLogger
}

SimpleLogging is the interface that our SimpleLogger implements. It's really only used for mocking when we need to test what's being logged.

Directories

Path Synopsis
matchers
Code generated by pegomock.
Code generated by pegomock.

Jump to

Keyboard shortcuts

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