csvlogger

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package csvlogger provides a simple CSV logger for Go. It is intented to store csv data in a file until the maximum file size is reached. Then a new file is created.

Index

Constants

This section is empty.

Variables

View Source
var SimulateFileSizeLimit = 0

SimulateFileSizeLimit can simulate a file too large error. Set it to a non-zero value to simulate a file size limit after n lines.

Functions

This section is empty.

Types

type DiskFull

type DiskFull struct{}

DiskFull is returned if the disk is full

func (*DiskFull) Error

func (m *DiskFull) Error() string

type FileSizeLimitReached

type FileSizeLimitReached struct{}

FileSizeLimitReached is returned if the file size limit is reached

func (*FileSizeLimitReached) Error

func (m *FileSizeLimitReached) Error() string

type Writer

type Writer struct {
	Comma rune // Comma is the field delimiter. It is set to ',' by NewWriter.
	// contains filtered or unexported fields
}

Writer is a CSV logger

func NewWriter

func NewWriter(outPath string, outFilePrefix string) *Writer

NewWriter creates a new CSV logger.

func (*Writer) Close

func (w *Writer) Close()

Close closes the Writer. subsequent writes to the Writer will go into a new file.

func (*Writer) Write

func (w *Writer) Write(record []string) error

Write writes a single CSV record to w. If file size limit is reached, a FileSizeLimitReached error is returned. The current file is closed and a subsequent write will go into a new file. If disk is full, a DiskFull error is returned.

Jump to

Keyboard shortcuts

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