@rbxts/rlog > RLogConfig > correlationGenerator
RLogConfig.correlationGenerator property
Function to generate correlation IDs.
Signature:
readonly correlationGenerator?: () => string;
Remarks
By default, Correlation IDs are generated via a combination of HttpService.GenerateGUID and the current time- to avoid conflicts.
If you specify your own function, it will be called anytime a new Correlation ID is requested.
Especially useful if you want to create Correlation IDs to match ids in your external database.
Example
function generateCorrelationID(): string {
return "1";
}
const config = { correlationGenerator: generateCorrelationID };
withLogContext(config, (context) => {
const logger = context.use();
logger.i("Player created", { player: player });
});
// > [INFO]: Player created
// > { "correlation_id": "1", "data": { "player": 1338 } }