Skip to content

LogRecord

luau
local Operator = require(game:GetService("ServerStorage").Operator)
local LogRecord = Operator.LogRecord

The record shapes the log panel reads, and the matching rules it searches with. Shared, so the client renders the same shapes the server produced.

Pure Luau with no Roblox API calls.

Types

Stream

luau
type Stream = "general" | "moderation"

general is the audit log rendered; moderation is actions recorded with context:logAction.

GeneralRecord

luau
type GeneralRecord = {
	kind: "general",
	id: string,
	at: number,
	jobId: string,
	userId: number?,
	userName: string,
	displayName: string,
	command: string,
	path: string,
	status: string,
	ok: boolean,
	reported: string?,
}

reported is "client" on a client-reported row and absent otherwise.

ModerationRecord

luau
type ModerationRecord = {
	kind: "moderation",
	id: string,
	at: number,
	jobId: string,
	action: string,
	severity: string,
	targetId: number?,
	targetName: string,
	targetDisplayName: string,
	reason: string?,
	duration: number?,
	moderatorId: number?,
	moderatorName: string,
	moderatorDisplayName: string,
}

Record

luau
type Record = GeneralRecord | ModerationRecord

Switch on kind.

Query

luau
type Query = {
	stream: Stream?,
	search: string?,
	days: number?,
	userId: number?,
	limit: number?,
	cursor: Cursor?,
}

Cursor

luau
type Cursor = { offset: number }

Opaque to callers. Hand back what a Page gave you.

Page

luau
type Page = {
	records: { Record },
	cursor: Cursor?,
	scanned: number,
	truncated: boolean,
}

cursor is non-nil when more records matched than fit.

Properties

PropertyValue
LogRecord.Streams{ general = "general", moderation = "moderation" }
LogRecord.Severitiesban, kick, wipe, warn, custom
LogRecord.DefaultSeverity"custom"

Functions

LogRecord.matches

luau
LogRecord.matches(record: Record, search: string?, userId: number?): boolean

Whether a record matches a search. Case-insensitive, substring, and matched against every field a moderator would type: names, display names, user IDs, command text, action, severity, reason and moderator.

An empty or nil search matches everything. A userId matches the record's subject or its moderator, so searching a user finds both what they did and what was done to them.

LogRecord.isStream

luau
LogRecord.isStream(value: any): boolean

Whitelist check. Used at the remote boundary before a stream name reaches a query.

LogRecord.isSeverity

luau
LogRecord.isSeverity(value: any): boolean

LogRecord.haystack

luau
LogRecord.haystack(record: Record): string

The lowercased text matches searches. Exposed for building your own filter.

LogRecord.subjectId / LogRecord.moderatorId

luau
LogRecord.subjectId(record: Record): number?
LogRecord.moderatorId(record: Record): number?

moderatorId is always nil for a general record.

Released under the MIT Licence.