...
Documentation
Documentation

# Package logger

## Overview ▹

## Overview ▾

## Index ▹

## Index ▾

### Package files

logger.go

## func SetLogger ¶

    func SetLogger(logger Logger)

SetLogger sets 'logger' to be used by the unidoc unipdf library.

## type ConsoleLogger ¶

ConsoleLogger is a logger that writes logs to the 'os.Stdout'

    type ConsoleLogger struct {
        LogLevel LogLevel
    }

### func NewConsoleLogger ¶

    func NewConsoleLogger(logLevel LogLevel) *ConsoleLogger

NewConsoleLogger creates new console logger.

### func (ConsoleLogger) Debug ¶

    func (l ConsoleLogger) Debug(format string, args ...interface{})

Debug logs debug message.

### func (ConsoleLogger) Error ¶

    func (l ConsoleLogger) Error(format string, args ...interface{})

Error logs error message.

### func (ConsoleLogger) Info ¶

    func (l ConsoleLogger) Info(format string, args ...interface{})

Info logs info message.

### func (ConsoleLogger) IsLogLevel ¶

    func (l ConsoleLogger) IsLogLevel(level LogLevel) bool

IsLogLevel returns true if log level is greater or equal than `level`. Can be used to avoid resource intensive calls to loggers.

### func (ConsoleLogger) Notice ¶

    func (l ConsoleLogger) Notice(format string, args ...interface{})

Notice logs notice message.

### func (ConsoleLogger) Trace ¶

    func (l ConsoleLogger) Trace(format string, args ...interface{})

Trace logs trace message.

### func (ConsoleLogger) Warning ¶

    func (l ConsoleLogger) Warning(format string, args ...interface{})

Warning logs warning message.

## type DummyLogger ¶

DummyLogger does nothing.

    type DummyLogger struct{}

### func (DummyLogger) Debug ¶

    func (DummyLogger) Debug(format string, args ...interface{})

Debug does nothing for dummy logger.

### func (DummyLogger) Error ¶

    func (DummyLogger) Error(format string, args ...interface{})

Error does nothing for dummy logger.

### func (DummyLogger) Info ¶

    func (DummyLogger) Info(format string, args ...interface{})

Info does nothing for dummy logger.

### func (DummyLogger) IsLogLevel ¶

    func (DummyLogger) IsLogLevel(level LogLevel) bool

IsLogLevel returns true from dummy logger.

### func (DummyLogger) Notice ¶

    func (DummyLogger) Notice(format string, args ...interface{})

Notice does nothing for dummy logger.

### func (DummyLogger) Trace ¶

    func (DummyLogger) Trace(format string, args ...interface{})

Trace does nothing for dummy logger.

### func (DummyLogger) Warning ¶

    func (DummyLogger) Warning(format string, args ...interface{})

Warning does nothing for dummy logger.

## type LogLevel ¶

LogLevel is the verbosity level for logging.

    type LogLevel int

Defines log level enum where the most important logs have the lowest values. I.e. level error = 0 and level trace = 5

    const (
        LogLevelTrace   LogLevel = 5
        LogLevelDebug   LogLevel = 4
        LogLevelInfo    LogLevel = 3
        LogLevelNotice  LogLevel = 2
        LogLevelWarning LogLevel = 1
        LogLevelError   LogLevel = 0
    )

## type Logger ¶

Logger is the interface used for logging in the unipdf package.

    type Logger interface {
        Error(format string, args ...interface{})
        Warning(format string, args ...interface{})
        Notice(format string, args ...interface{})
        Info(format string, args ...interface{})
        Debug(format string, args ...interface{})
        Trace(format string, args ...interface{})
        IsLogLevel(level LogLevel) bool
    }

Log is a global instance of the logger instance. It is thread safe, i.e. can be used by multiple go routines.

    var Log Logger = DummyLogger{}

## type WriterLogger ¶

WriterLogger is the logger that writes data to the Output writer

    type WriterLogger struct {
        LogLevel LogLevel
        Output   io.Writer
    }

### func NewWriterLogger ¶

    func NewWriterLogger(logLevel LogLevel, writer io.Writer) *WriterLogger

NewWriterLogger creates new 'writer' logger.

### func (WriterLogger) Debug ¶

    func (l WriterLogger) Debug(format string, args ...interface{})

Debug logs debug message.

### func (WriterLogger) Error ¶

    func (l WriterLogger) Error(format string, args ...interface{})

Error logs error message.

### func (WriterLogger) Info ¶

    func (l WriterLogger) Info(format string, args ...interface{})

Info logs info message.

### func (WriterLogger) IsLogLevel ¶

    func (l WriterLogger) IsLogLevel(level LogLevel) bool

IsLogLevel returns true if log level is greater or equal than `level`. Can be used to avoid resource intensive calls to loggers.

### func (WriterLogger) Notice ¶

    func (l WriterLogger) Notice(format string, args ...interface{})

Notice logs notice message.

### func (WriterLogger) Trace ¶

    func (l WriterLogger) Trace(format string, args ...interface{})

Trace logs trace message.

### func (WriterLogger) Warning ¶

    func (l WriterLogger) Warning(format string, args ...interface{})

Warning logs warning message.