Skip to main content

@rbxts/rlog > LogSinkCallback

LogSinkCallback type

Type representing a callback function for consuming log entries, or a "sink".

Sinks are generally used to send logs to an external database or service, but they can also be used to filter logs by "consuming" them.

If your callback returns true, then the log will be stopped, and no further sinks will be called. The LogEntry will also not be logged to the console.

Signature:

export type LogSinkCallback = (entry: LogEntry) => boolean | void;

References: LogEntry

Remarks

You should not yield in sinks. If you're sending data to an external service, do so via a queue that gets dispatched in a different thread.

Example

const logger = new rLog({
sinks: [
(entry) => {
someExternalDBFunction(entry);
},
(entry) => {
return true;
},
(entry) => {
// never throws because the previous sink returned true
error("Messages should not log to the console");
},
],
});

logger.i("Hello world!");