Quick Start
rLog is a Context-based server-side logging framework for ROBLOX, designed to help organize and structure your logging process.
This guide will walk you through the basics of getting started, in just a few steps.
Installation
First, install rLog with your preferred package manager:
- npm
- pnpm
- yarn
npm install @rbxts/rlog
pnpm add @rbxts/rlog
yarn add @rbxts/rlog
Start using rLog
Once installed, you can immediately start with creating an rLog instance.
import { rLog } from "@rbxts/rlog";
// Initialize the logger
const logger = new rLog();
You can also use the default ("global") instance if you don't need (or want) to create your own.
import { rLogger } from "@rbxts/rlog";
Logging your first message
Logging messages is easy and straightforward with rLog.
Just call the method for your intended LogLevel
, and pass in a message.
logger.info("Hello world!");
Adding data to your message
By passing a table as the second parameter to your logging method, you can optionally output data with your message.
logger.info("Hello world!", {
user: "Daymon",
action: "start",
});
{
data: {
user: "Daymon",
action: "start"
}
}
ROBLOX data types
The table you pass is automatically encoded, and even supports ROBLOX data types!
logger.info("Hello world!", {
position: new Vector3(1, 5, 10),
rotation: new CFrame(),
});
{
data: {
position: { X: 1, Y: 5, Z: 10 },
rotation: "CFrame(0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1)"
}
}
Configuration
If you need more control over your logging setup, you can configure rLog with enrichers, custom log levels, and more:
import { rLog, LogLevel } from "@rbxts/rlog";
// Advanced setup with custom serialization and enrichers
const logger = new rLog({
minLogLevel: LogLevel.WARNING,
tag: "Main",
enrichers: [
(entry) => {
entry.encoded_data.timestamp = DateTime.now().ToIsoDate();
return entry;
},
],
serialization: {
encodeFunctions: true,
},
});
Next Steps
If you're wanting to learn more, feel free to check out any of the following resources: