Skip to content

logging — Advanced Logging

Source Code: BLuau/Libraries/logging/__init.luau

Information

This module defines functions that implement a flexible event logging system for libraries and your code.

The main advantage of using the logging API provided by a standard library module is that all BLuau modules can use logging, ensuring that your log can include your own messages along with third-party module messages.

The only part of BLuau that does not use logging is the internal files, in order to avoid conflicts and looping issues in certain cases.

The logging system includes different priority levels, which you can define yourself. It is possible to configure the logger's behavior and validate specific logging levels within the Roblox environment.

Configuration

ParametersDescriptions
Module.__levelsLogging priority levels.
Module.__loggerEnable or disable log recording.

These parameters can be modified using the logging.config() function, which allows configuring the module.

Functions


Configure the Module

logging.config(logger, levelName)

Configures the logging module.

This function must be called at server startup and should not be called multiple times to avoid conflicts between different requests.

luau
logging.config(true, "INFO")

Parameters

ArgumentsDescriptions
logger: Boolean?Enables or disables log recording.
levelName: String?Logging priority level.

Returns

ValuesDescriptions
TableContains the last valid module configuration.
Boolean?Returns false if invalid values are provided.

Send a Log

logging.log(message, levelName)

Records a message with the specified logging level.

luau
logging.log("YOUR_MESSAGE", "LEVEL_NAME")

Parameters

ArgumentsDescriptions
message: String?The message to log.
levelName: String?Logging priority level.

Returns

ValuesDescriptions
TableContains the log entry details.

Retrieve Logs

logging:GetLog()

Retrieves log entries stored in the Logger module.

Clear Logs

logging:Clear()

Clears all recorded log entries.

Released under the Apache-2.0 License.