Logger
Event based logger object. More information at logger.
Events
Events consist of an unix timestamp, a level and an attached message.
type Event = {
Time: number,
Type: "Info" | "Debug" | "Warn" | "Error" | "Fatal",
Message: string
}The Error log level doesn't stop code execution - Fatal on the other hand, halts execution and throws an error to the developer console.
Types
Event
Event = {
Time: number,
Type: "Info" | "Debug" | "Warn" | "Error" | "Fatal",
Message: string
}Methods
new
Logger.new() → LoggerConstructs a Logger.
Info
Logger.Info(
self: Logger,
Message: string
) → EventLogs at the Info [🔵] level.
Debug
Logger.Debug(
self: Logger,
Message: string
) → EventLogs at the Debug [🟡] level.
Warn
Logger.Warn(
self: Logger,
Message: string
) → EventLogs at the Warn [🟠] level.
Error
Logger.Error(
self: Logger,
Message: string
) → EventLogs at the Error [🔴] level.
Fatal
Logger.Fatal(
self: Logger,
Message: string
) → EventLogs at the Fatal [❌] level and spits out an error to the developer console, halting code execution.
Assert
Logger.Assert(
self: Logger,
Condition: boolean,
Message: string
) → Event?Performs a soft assertion at the Error [🔴] level.
Assert
Logger.FatalAssert(
self: Logger,
Condition: boolean,
Message: string
) → Event?Performs a fatal assertion at the Fatal [❌] level, halting execution and erroring to the developer console if the condition is false.
OnEvent
Logger.OnEvent(
self: Logger,
Type: EventType,
Callback: (Event) → void
) → () → void -- Used to disconnectCalled every time an event of the specified level happens.
As an example, this logs every debug event to the developer console:
Logger:OnEvent("Debug", function(Event)
print(`[🟡][🕒{Event.Time}]: {Event.Message}`)
end)OnAnyEvent
Logger.OnAnyEvent(
self: Logger,
Callback: (Event) → void
) → () → void -- Used to disconnectCalled every time any event happens.
Riptide