logging

package
v0.0.0-...-b2113b7 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package logging has utilities to aid in recording logs for tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DirectoryLogger

type DirectoryLogger struct {
	Directory string
	// contains filtered or unexported fields
}

DirectoryLogger manages a set of log.Loggers that each write to a different file within a single directory. To write to a file named foo.txt in that directory, call dirLog.ToFile("foo.txt") and use the log.Logger that it returns. The ToMainLog method is a shorthand that logs to a file called main_log.txt.

It is the caller's responsibility to call Close() when done with a DirectoryLogger. After calling Close(), the DirectoryLogger and the log.Loggers it returns should not be used anymore.

func NewDirectoryLogger

func NewDirectoryLogger(dir string) (*DirectoryLogger, error)

NewDirectoryLogger returns a new DirectoryLogger managing the files in the given directory.

func (*DirectoryLogger) Close

func (dirLog *DirectoryLogger) Close() error

Close closes all open files that have been used for logging so far.

func (*DirectoryLogger) ToFile

func (dirLog *DirectoryLogger) ToFile(file string) *log.Logger

ToFile returns a Logger that writes to a file with the given path inside the directory managed by this DirectoryLogger.

func (*DirectoryLogger) ToMainLog

func (dirLog *DirectoryLogger) ToMainLog() *log.Logger

ToMainLog returns a Logger that writes to the main log (main_log.txt).

Jump to

Keyboard shortcuts

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