file

package
v0.0.0-...-424d171 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package file implements the output of logs to a file.

Configuration file supports either writing to a file or a directory with random names. delimiter is required. This is the string to write between log entries. Normally a new line "\n"

output:
  type: file
  filename: "/var/tmp/rally.ndjson"
  delimiter: "/n"

or

output:
  type: file
  directory: "/var/tmp"
  pattern: "rally_*"
  delimiter: "\r\n"

directory and pattern are used in os.CreateTemp call

Index

Constants

View Source
const Name = "file"

OutputName is the name of the output in the configuration file and registry

Variables

This section is empty.

Functions

func New

func New(cfg *ucfg.Config) (output.Output, error)

New is the Factory for creating a new file output. Calling this results in a file handle being opened to write the log data to.

Types

type Output

type Output struct {
	// contains filtered or unexported fields
}

Output stores pointer to an io.WriteCloser. This is where the log entries will be written. It also stores the delimiter that will be added between log entries.

func (*Output) Close

func (o *Output) Close() error

Close closes the io.WriteCloser. Writes after this will fail.

func (*Output) NewInterval

func (o *Output) NewInterval() error

func (*Output) Write

func (o *Output) Write(b []byte) (n int, err error)

Write writes the log entry to the file handle that is opened with new and appends the delimiter.

Jump to

Keyboard shortcuts

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