Skip to main content
BeagleLog is the abstract base class that all log types extend. It provides core functionality for log entries including identification, timestamps, messages, and filtering.

Properties

id
string
required
Unique identifier for the log entry. Auto-generated using nanoid(6) if not provided.
time
Date
required
Timestamp when the log was created. Automatically set to new Date() during construction.
message
string
required
The log message content.
level
LogLevel
default:"info"
The severity level of the log. Can be one of: 'loading', 'info', 'warning', 'error', or 'success'.

Constructor

message
string
required
The log message content.
level
LogLevel
default:"info"
Optional severity level. One of: 'loading' | 'info' | 'warning' | 'error' | 'success'.
id
string
Optional custom ID. If not provided, a unique 6-character ID is generated automatically.

Methods

filter()

Filters the log based on a search query.
query
string
required
The search query to filter by.
Returns: boolean - true if the log’s message contains the query (case-insensitive), false otherwise.
const log = new MessageLog('User logged in successfully');
log.filter('logged'); // true
log.filter('error'); // false

Type Definitions

type LogLevel = 'loading' | 'info' | 'warning' | 'error' | 'success';

abstract class BeagleLog {
  id: string;
  time: Date;
  message: string;
  level: LogLevel;

  constructor(message: string, level?: LogLevel, id?: string);
  filter(query: string): boolean;
}

Build docs developers (and LLMs) love