logging

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package logging implements logging functionality for data and errors

Index

Constants

View Source
const (
	// ISOformatMilli - ISO 8601 date and time format, with UTC offset and milliseconds
	ISOformatMilli = "2006-01-02T15:04:05.000-07:00"
	// LogSep - globally used separator for parameters in text files
	LogSep = "\t"
)

Variables

This section is empty.

Functions

func AppendCurrentDay

func AppendCurrentDay(dst string) string

AppendCurrentDay takes a base path and appends subdirectories /year/month/year-month-day

func DateDifferent

func DateDifferent(now, prev *time.Time) bool

DateDifferent checks if the date of time.Time "now" is greater then that of "prev"

func EnsurePath

func EnsurePath(dst string) error

EnsurePath makes sure that the given path is valid and exists. If it does not exist, the function attempts to create it

func FloorHMS

func FloorHMS(t time.Time, h, m, s int) (time.Time, error)

FloorHMS floors a given time t to multiples of hours h, minuts m and seconds s. nanoseconds are always set to zero. returns a new time.Time.

func PrependDate

func PrependDate(t *time.Time, s string) string

PrependDate prepends the current date to a string and separates it with an underscore, YYYYMMDD_, from a given time.Time t

func PrependDatetime

func PrependDatetime(t *time.Time, s string) string

PrependDatetime prepends current date and time to a string, YYYYMMDD_HHMMSS_, from a given time.Time t

func PrependTime

func PrependTime(t *time.Time, s string) string

PrependTime prepends the current time to a string and separates it with an underscore, HHMMSS_, from a given time.Time t

Types

type FileConfig

type FileConfig struct {

	// base directory, where a new year-month-day durectory structure is created
	BaseDir string

	// a subdirectory to create for the current day
	InstrumentDir string

	// a name extension that will be appended. prefix is always a hms time string.
	NameExt string

	// file name creation: floor hours minutes seconds to multiples of...
	// settting all to 1 will skip flooring in UpdateFname()
	FloorHMS [3]int

	// the pointer currently used for writing:
	ActiveFilePtr *os.File

	// a header string to write to a new file
	Header string
}

FileConfig holds configuration for a data log file.

func (*FileConfig) UpdateFname

func (c *FileConfig) UpdateFname() (err error)

UpdateFname checks if the current filename is still valid. If filename isn't defined yet or invalid, a new one is created. An error will be returned if file operations fail.

Jump to

Keyboard shortcuts

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