Documentation ¶
Index ¶
Constants ¶
const RotateDaily = rotateDaily(0)
The RotateDaily strategy will ensure that the file is rotated if it is of non zero size when a call to Write() arrives on a day different from the day when the current file was created.
const RotateNever = rotateNever(0)
The RotateNever strategy will always answer false to the RotateNow question
Variables ¶
var IsTerminal = term.IsTerminal
IsTerminal returns whether the given file descriptor is a terminal
Functions ¶
func InitContext ¶
InitContext sets up standard Telepresence logging for a background process
Types ¶
type Formatter ¶
type Formatter struct {
// contains filtered or unexported fields
}
Formatter formats log messages for Telepresence client
func NewFormatter ¶
type RotatingFile ¶
type RotatingFile struct {
// contains filtered or unexported fields
}
func OpenRotatingFile ¶
func OpenRotatingFile( logfilePath string, timeFormat string, localTime bool, captureStd bool, fileMode os.FileMode, strategy RotationStrategy, maxFiles uint16, ) (*RotatingFile, error)
OpenRotatingFile opens a file with the given name after first having created the directory that it resides in and all parent directories. The file is opened write only.
Parameters:
- dirName: full path to the directory of the log file and its backups
- fileName: name of the file that should opened (relative to dirName)
- timeFormat: the format to use for the timestamp that is added to rotated files
- localTime: if true, use local time in timestamps, if false, use UTC
- captureStd: if true, override os.Stdout and os.Stderr with the file descriptor of the current logfile
- stdLogger: if not nil, all writes to os.Stdout and os.Stderr will be redirected to this logger as INFO level messages prefixed with <stdout> or <stderr>
- fileMode: the mode to use when creating new files the file
- strategy: determines when a rotation should take place
- maxFiles: maximum number of files in rotation, including the currently active logfile. A value of zero means unlimited
func (*RotatingFile) BirthTime ¶
func (rf *RotatingFile) BirthTime() time.Time
BirthTime returns the time when the current file was created. The time will be local if the file was opened with localTime == true and UTC otherwise.
func (*RotatingFile) Rotate ¶
func (rf *RotatingFile) Rotate() (err error)
Rotate closes the currently opened file and renames it by adding a timestamp between the file name and its extension. A new file empty file is then opened to receive subsequent data.
func (*RotatingFile) Size ¶
func (rf *RotatingFile) Size() int64
Size returns the size of the current file
type RotationStrategy ¶
type RotationStrategy interface {
RotateNow(file *RotatingFile, writeSize int) bool
}
A RotationStrategy answers the question if it is time to rotate the file now. It is called prior to every write so it needs to be fairly quick.
func NewRotateOnce ¶
func NewRotateOnce() RotationStrategy
type SysInfo ¶ added in v2.4.0
type SysInfo interface { fmt.Stringer BirthTime() time.Time SetOwnerAndGroup(name string) error HaveSameOwnerAndGroup(SysInfo) bool }
SysInfo represents the elaborate info in a FileInfo.Sys(). The implementations are os specific.
Unix:
info.Sys().(*syscall.Stat_t)
Windows:
info.Sys().(*syscall.Win32FileAttributeData)