Triton
Overview
The Triton
class provides a singleton implementation for logging in Lightning Web Components (LWC) and Aura components. It manages log buffering, transaction context, and component-specific templates.
Constructor
Triton()
Description: Creates or returns the singleton instance of the Triton logger
Returns: Triton instance
Example:
Transaction Methods
startTransaction()
Description: Generates and stores a new transaction ID and starts the auto-flush monitor
Returns:
{string}
The generated transaction IDExample:
resumeTransaction(transactionId)
Description: Resumes a transaction using an existing transaction ID
Parameters:
transactionId
:{string}
Existing transaction ID to resume
Example:
stopTransaction()
Description: Stops the current transaction and auto-flush monitor, flushes remaining logs
Example:
Logging Methods
exception(error)
Description: Creates an error log from a JavaScript Error object
Parameters:
error
:{Error}
JavaScript Error object to log
Returns:
{TritonBuilder}
Builder instance for chainingExample:
error(type, area)
Description: Creates an error level log
Parameters:
type
:{string}
Log type from TYPE enumarea
:{string}
Log area from AREA enum
Returns:
{TritonBuilder}
Builder instance for chainingExample:
warning(type, area)
Description: Creates a warning level log
Parameters:
type
:{string}
Log type from TYPE enumarea
:{string}
Log area from AREA enum
Returns:
{TritonBuilder}
Builder instance for chainingExample:
debug(type, area)
Description: Creates a debug level log
Parameters:
type
:{string}
Log type from TYPE enumarea
:{string}
Log area from AREA enum
Returns:
{TritonBuilder}
Builder instance for chainingExample:
info(type, area)
Description: Creates an info level log
Parameters:
type
:{string}
Log type from TYPE enumarea
:{string}
Log area from AREA enum
Returns:
{TritonBuilder}
Builder instance for chainingExample:
Template Methods
setTemplate(builder)
Description: Sets a builder template that can be re-used for the calling component
Parameters:
builder
:{TritonBuilder}
Builder to be used as template
Example:
fromTemplate()
Description: Creates a new builder from the saved template for the calling component
Returns:
{TritonBuilder}
New builder instanceExample:
Buffer Management
flush()
Description: Sends all buffered logs to the server and clears the buffer
Returns:
{Promise}
Promise that resolves when logs are flushedExample:
log(builder)
Description: Adds a log builder to the buffer
Parameters:
builder
:{TritonBuilder}
Builder instance to log
Returns:
{TritonBuilder}
The builder instanceExample:
logNow(builder)
Description: Immediately flushes a single log builder
Parameters:
builder
:{TritonBuilder}
Builder instance to log
Returns:
{Promise}
Promise that resolves when the log is flushedExample:
Enums
AREA
CATEGORY
LEVEL
TYPE
Last updated