Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

log.file

import log

Everything here is re-exported by log, so import log is enough and the names are called as log.*. Importing log.file on its own works too and reaches the same definitions.

FileTransport: sends log streams to a file on disk, with optional size-based rotation.

Classes

FileTransport

class log.FileTransport < Transport

FileTransport is a log transport that facilitates sending log streams to an on-disk file.

Fields

FieldTypeDescription
file

Constructor

log.FileTransport(path: string)

Returns a new instance of FileTransport and opens a file handle to the the file specified in the path.

Parameters

  • path (string)

FileTransport.set_max_bytes()

log.FileTransport.set_max_bytes(n: ?number)

Sets the size, in bytes, past which the log file is rotated to <path>.1 (shifting any existing numbered backups up by one) and a fresh file is opened at path. Rotation is disabled (nil) by default.

Parameters

  • n (?number)

Returns — self

FileTransport.set_backup_count()

log.FileTransport.set_backup_count(n: number)

Sets how many rotated backups (<path>.1 through <path>.<n>) are kept. The oldest backup beyond this count is deleted on the next rotation. Default: 5.

Parameters

  • n (number)

Returns — self

FileTransport.write()

log.FileTransport.write(message, level)

FileTransport.flush()

log.FileTransport.flush()

FileTransport.close()

log.FileTransport.close()