Skip to content

Logging

Spice
import "std/io/logging";

LogFile struct

A log file that writes timestamped log messages to a file on disk and, optionally, also mirrors them to the console.

Constructors

ctor

Spice
public p LogFile.ctor(const FilePath& filePath, bool onlyToFile = false)

Construct a log file, opening the file at the given path in append mode

Parameters

Name Type Description
filePath const FilePath& Path to the log file
onlyToFile bool If true, messages are only written to the file and not also to the console (default: false)

dtor

Spice
public p LogFile.dtor()

Destruct the log file, closing the underlying file handle

Methods

logDebug

Spice
public p LogFile.logDebug(string message)

Log a message at debug level to the file (and the console unless onlyToFile is set)

Parameters

Name Type Description
message string Message to log

logInfo

Spice
public p LogFile.logInfo(string message)

Log a message at info level to the file (and the console unless onlyToFile is set)

Parameters

Name Type Description
message string Message to log

logWarning

Spice
public p LogFile.logWarning(string message)

Log a message at warning level to the file (and the console unless onlyToFile is set)

Parameters

Name Type Description
message string Message to log

logError

Spice
public p LogFile.logError(string message)

Log a message at error level to the file (and the console unless onlyToFile is set)

Parameters

Name Type Description
message string Message to log

Functions

logDebug

Spice
public p logDebug(string message)

Log a message at debug level to the console

Parameters

Name Type Description
message string Message to log

logInfo

Spice
public p logInfo(string message)

Log a message at info level to the console

Parameters

Name Type Description
message string Message to log

logWarning

Spice
public p logWarning(string message)

Log a message at warning level to the console

Parameters

Name Type Description
message string Message to log

logError

Spice
public p logError(string message)

Log a message at error level to the console

Parameters

Name Type Description
message string Message to log