Pharos Triton
  • 🔱About Pharos Triton
  • 🏁Installing Pharos Triton
  • Apex Logging Basics
  • Common Apex Usage Patters
    • Batch Logging
    • Integration Logs
    • Apex Rest Logging
    • Full Control with TritonBuilder
  • Beyond Apex
    • LWC
    • 🔄LWC Transaction Management
    • ⚡LWC and Apex
    • 💾Platform Cache for Transactions
    • Flows
    • 〰️LWC, Apex and Flows
  • 📖Methods Reference
    • 📔Apex
      • Triton
      • TritonBuilder
      • TritonTypes
      • TritonLwc
        • ComponentLog
        • Component
        • Error
        • RuntimeInfo
      • TritonFlow
        • FlowLog
      • TritonHelper
        • PostProcessingControlsBuilder
      • LogBuilder
    • LWC
      • Triton
      • TritonBuilder
      • TritonUtils
  • Help and Support
Powered by GitBook
On this page
  • Overview
  • Constructor
  • Triton()
  • Transaction Methods
  • startTransaction()
  • resumeTransaction(transactionId)
  • stopTransaction()
  • Logging Methods
  • exception(error)
  • error(type, area)
  • warning(type, area)
  • debug(type, area)
  • info(type, area)
  • Template Methods
  • setTemplate(builder)
  • fromTemplate()
  • Buffer Management
  • flush()
  • log(builder)
  • logNow(builder)
  • Enums
  • AREA
  • CATEGORY
  • LEVEL
  • TYPE
  1. Methods Reference
  2. LWC

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:

const triton = new Triton();

Transaction Methods

startTransaction()

  • Description: Generates and stores a new transaction ID and starts the auto-flush monitor

  • Returns: {string} The generated transaction ID

  • Example:

const transactionId = triton.startTransaction();

resumeTransaction(transactionId)

  • Description: Resumes a transaction using an existing transaction ID

  • Parameters:

    • transactionId: {string} Existing transaction ID to resume

  • Example:

triton.resumeTransaction('existing-transaction-id');

stopTransaction()

  • Description: Stops the current transaction and auto-flush monitor, flushes remaining logs

  • Example:

triton.stopTransaction();

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 chaining

  • Example:

triton.exception(new Error('Something went wrong'));

error(type, area)

  • Description: Creates an error level log

  • Parameters:

    • type: {string} Log type from TYPE enum

    • area: {string} Log area from AREA enum

  • Returns: {TritonBuilder} Builder instance for chaining

  • Example:

triton.error(TYPE.FRONTEND, AREA.COMMUNITY);

warning(type, area)

  • Description: Creates a warning level log

  • Parameters:

    • type: {string} Log type from TYPE enum

    • area: {string} Log area from AREA enum

  • Returns: {TritonBuilder} Builder instance for chaining

  • Example:

triton.warning(TYPE.FRONTEND, AREA.ACCOUNTS);

debug(type, area)

  • Description: Creates a debug level log

  • Parameters:

    • type: {string} Log type from TYPE enum

    • area: {string} Log area from AREA enum

  • Returns: {TritonBuilder} Builder instance for chaining

  • Example:

triton.debug(TYPE.FRONTEND, AREA.OPPORTUNITY_MANAGEMENT);

info(type, area)

  • Description: Creates an info level log

  • Parameters:

    • type: {string} Log type from TYPE enum

    • area: {string} Log area from AREA enum

  • Returns: {TritonBuilder} Builder instance for chaining

  • Example:

triton.info(TYPE.FRONTEND, AREA.REST_API);

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:

triton.setTemplate(builder.type(TYPE.FRONTEND).area(AREA.COMMUNITY));

fromTemplate()

  • Description: Creates a new builder from the saved template for the calling component

  • Returns: {TritonBuilder} New builder instance

  • Example:

const builder = triton.fromTemplate().summary('New log entry');

Buffer Management

flush()

  • Description: Sends all buffered logs to the server and clears the buffer

  • Returns: {Promise} Promise that resolves when logs are flushed

  • Example:

await triton.flush();

log(builder)

  • Description: Adds a log builder to the buffer

  • Parameters:

    • builder: {TritonBuilder} Builder instance to log

  • Returns: {TritonBuilder} The builder instance

  • Example:

triton.log(builder.summary('Operation completed'));

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 flushed

  • Example:

await triton.logNow(builder.summary('Critical operation'));

Enums

AREA

{
    ACCOUNTS: 'ACCOUNTS',
    COMMUNITY: 'COMMUNITY',
    LEAD_CONVERSION: 'LEAD_CONVERSION',
    OPPORTUNITY_MANAGEMENT: 'OPPORTUNITY_MANAGEMENT',
    REST_API: 'REST_API'
}

CATEGORY

{
    LWC: 'LWC',
    AURA: 'Aura',
    WARNING: 'Warning',
    DEBUG: 'Debug',
    EVENT: 'Event'
}

LEVEL

{
    ERROR: 'ERROR',
    WARNING: 'WARNING',
    INFO: 'INFO',
    DEBUG: 'DEBUG',
    FINE: 'FINE',
    FINER: 'FINER',
    FINEST: 'FINEST'
}

TYPE

{
    BACKEND: 'Backend',
    FRONTEND: 'Frontend'
}
PreviousLWCNextTritonBuilder

Last updated 2 months ago

📖