common

package
v0.0.0-...-1effa6f Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2021 License: AGPL-3.0, AGPL-3.0-only Imports: 6 Imported by: 12

Documentation

Overview

Package common contains common properties used by the subpackages.

Index

Constants

View Source
const Version = "3.6.0"

Version holds version information, when bumping this make sure to bump the released at stamp also.

Variables

View Source
var ReleasedAt = time.Date(releaseYear, releaseMonth, releaseDay, releaseHour, releaseMin, 0, 0, time.UTC)

Functions

func SetLogger

func SetLogger(logger Logger)

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

func UtcTimeFormat

func UtcTimeFormat(t time.Time) string

Types

type ConsoleLogger

type ConsoleLogger struct {
	LogLevel LogLevel
}

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

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

type DummyLogger struct{}

DummyLogger does nothing.

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

type LogLevel int

LogLevel is the verbosity level for logging.

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

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

type Logger

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
}

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

var Log Logger = DummyLogger{}

type WriterLogger

type WriterLogger struct {
	LogLevel LogLevel
	Output   io.Writer
}

WriterLogger is the logger that writes data to the Output 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.

Jump to

Keyboard shortcuts

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