file

package
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: May 10, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package file defines the logging file stream and file stream creation strategy to be integrated into the logging package stream factory instance.

Index

Constants

View Source
const (
	// ID defines the application container registration string for the
	// file stream strategy.
	ID = stream.ID + ".file"
	// RotatingID defines the application container registration string for
	// the rotating file stream strategy.
	RotatingID = ID + "-rotating"
)
View Source
const (
	// RotatingType defines the value to be used to declare a
	// file Log stream type that rotates regarding the current date.
	RotatingType = "rotating-file"
)
View Source
const (
	// Type defines the value to be used to declare a
	// file Log stream type.
	Type = "file"
)

Variables

This section is empty.

Functions

func NewRotatingWriter

func NewRotatingWriter(
	fs afero.Fs,
	file string,
) (io.Writer, error)

NewRotatingWriter generate a new rotating file writer instance.

func NewStream

func NewStream(
	writer io.Writer,
	formatter log.IFormatter,
	channels []string,
	level log.Level,
) (log.IStream, error)

NewStream generate a new file log stream instance.

Types

type Provider

type Provider struct{}

Provider defines the slate.config module service provider to be used on the application initialization to register the config service.

func (Provider) Boot

func (p Provider) Boot(
	container slate.IContainer,
) error

Boot will start the configuration config instance by calling the configuration loader with the defined provider base entry information.

func (Provider) Register

func (Provider) Register(
	container slate.IContainer,
) error

Register will register the configuration section instances in the application container.

type RotatingStreamStrategy

type RotatingStreamStrategy struct {
	StreamStrategy
}

RotatingStreamStrategy define a new rotating file log stream generation strategy.

func NewRotatingStreamStrategy

func NewRotatingStreamStrategy(
	fs afero.Fs,
	formatterFactory log.IFormatterFactory,
) (*RotatingStreamStrategy, error)

NewRotatingStreamStrategy generate a new rotating file log stream generation strategy.

func (RotatingStreamStrategy) Accept

func (s RotatingStreamStrategy) Accept(
	cfg config.IConfig,
) bool

Accept will check if the stream factory strategy can instantiate a stream where the data to check comes from a configuration partial instance.

func (RotatingStreamStrategy) Create

func (s RotatingStreamStrategy) Create(
	cfg config.IConfig,
) (log.IStream, error)

Create will instantiate the desired stream instance where the initialization data comes from a configuration instance.

type RotatingWriter

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

RotatingWriter defines an output writer used by a file stream that will use a dated file for target output.

func (*RotatingWriter) Close

func (w *RotatingWriter) Close() error

Close satisfies the Closable interface.

func (*RotatingWriter) Write

func (w *RotatingWriter) Write(
	output []byte,
) (int, error)

Write satisfies the io.Writer interface.

type Stream

type Stream struct {
	stream.Stream
}

Stream defines an instance to a file log output stream.

func (*Stream) Close

func (s *Stream) Close() error

Close will terminate the stream stored writer instance.

type StreamStrategy

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

StreamStrategy defines a file log stream generation strategy.

func NewStreamStrategy

func NewStreamStrategy(
	fs afero.Fs,
	formatterFactory log.IFormatterFactory,
) (*StreamStrategy, error)

NewStreamStrategy generates a new file log stream generation strategy instance.

func (StreamStrategy) Accept

func (s StreamStrategy) Accept(
	cfg config.IConfig,
) bool

Accept will check if the stream factory strategy can instantiate a stream where the data to check comes from a configuration partial instance.

func (StreamStrategy) Create

func (s StreamStrategy) Create(
	cfg config.IConfig,
) (log.IStream, error)

Create will instantiate the desired stream instance where the initialization data comes from a configuration instance.

Jump to

Keyboard shortcuts

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