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
  • Transaction Cache Methods
  • Stack Trace Methods
  • Runtime Info Formatting
  • Utility Methods
  • Builder Class
  • Runtime Information Components
  1. Methods Reference
  2. Apex

TritonHelper

The TritonHelper class provides utility methods and builder classes for the Triton logging framework.

This class is mostly for internal use and includes functionality for log level management, UUID generation, HTTP request/response serialization, and message formatting.

Transaction Cache Methods

cacheTransactionId

public static void cacheTransactionId(String transactionId)

Saves transaction ID to platform cache with user-specific key. Silently handles cache failures.

Parameters:

  • transactionId - Transaction ID to cache

getCachedTransactionId

public static String getCachedTransactionId()

Retrieves transaction ID from platform cache using user-specific key.

Returns:

  • Cached transaction ID or null if not found

clearCachedTransactionId

public static void clearCachedTransactionId()

Clears transaction ID from platform cache.

Stack Trace Methods

getCurrentStackTrace

public static String getCurrentStackTrace()

Returns the current stack trace as a string, excluding any Triton-related entries.

Returns:

  • Filtered stack trace with lines joined by newline characters

getOperation

public static String getOperation(String stackTrace)

Extracts the operation (Class.Method) from a stack trace string, taking the topmost non-Triton entry.

Parameters:

  • stackTrace - The stack trace string to parse

Returns:

  • String in format "ClassName.MethodName"

Runtime Info Formatting

formatLwcRuntimeInfo

public static String formatLwcRuntimeInfo(TritonLwc.RuntimeInfo runtime)

Formats runtime information from LWC into a readable string, including environment, performance, memory, network, and device details.

Parameters:

  • runtime - The runtime info object to format

Returns:

  • Formatted string with all runtime details

Utility Methods

buildLogLevelKey

public static String buildLogLevelKey(String category, String type, String area)

Creates a key for log level based on category, type, and area parameters.

Parameters:

  • category - Log category field

  • type - Log type field

  • area - Log functional area field

Returns:

  • String in the format: Category:{0};Type:{1};Area:{2}

compareLevel

public static Boolean compareLevel(TritonTypes.Level value, TritonTypes.Level toCompare)

Compares two log levels to determine if logging should proceed.

Parameters:

  • value - The level to compare against (from settings)

  • toCompare - The level being compared (from log)

Returns:

  • true if value is greater than or equal to toCompare

  • false if value is lower than toCompare

generateUUID4

public static String generateUUID4()

Generates a UUID (Universal Unique Identifier) version 4. Used to create transaction IDs.

Returns:

  • String containing a UUID4 formatted identifier

toJson (HTTP)

public static String toJson(HttpRequest request, HttpResponse response)

Serializes HTTP request and response objects to JSON format for integration logging.

Parameters:

  • request - HttpRequest instance

  • response - HttpResponse instance

Returns:

  • JSON string containing formatted request and response data

toJson (REST)

public static String toJson(RestRequest request, RestResponse response)

Serializes REST request and response objects to JSON format for integration logging.

Parameters:

  • request - RestRequest instance

  • response - RestResponse instance

Returns:

  • JSON string containing formatted request and response data

formatMessage (Single Parameter)

public static String formatMessage(String template, String param)

Formats a message by replacing {0} placeholder with the provided parameter.

Parameters:

  • template - Message template containing {0} placeholder

  • param - Parameter to replace the placeholder

Returns:

  • Formatted message string

formatMessage (Multiple Parameters)

public static String formatMessage(String template, List<String> params)

Formats a message by replacing {0}, {1}, etc. placeholders with the provided parameters.

Parameters:

  • template - Message template containing numbered placeholders

  • params - List of parameters to replace the placeholders

Returns:

  • Formatted message string

Builder Class

PostProcessingControlsBuilder

Methods

public PostProcessingControlsBuilder auditTrail(Boolean value)
public PostProcessingControlsBuilder deployResult(Boolean value)
public PostProcessingControlsBuilder installedPackages(Boolean value)
public PostProcessingControlsBuilder area(Boolean value)
public PostProcessingControlsBuilder pendingJobs(Boolean value)
public PostProcessingControlsBuilder relatedObjects(Boolean value)
public PostProcessingControlsBuilder stackTrace(Boolean value)
public PostProcessingControlsBuilder userInfo(Boolean value)
public PostProcessingControlsBuilder totalActiveSession(Boolean value)
public PostProcessingControlsBuilder setAll(Boolean value)

Each method controls a specific aspect of post-processing:

  • auditTrail - Controls fetching of recent audit trail

  • deployResult - Controls fetching of recent deployments

  • installedPackages - Controls fetching of installed package count

  • area - Controls automatic functional area setting

  • pendingJobs - Controls fetching of pending jobs in flow queue

  • relatedObjects - Controls fetching of related object names

  • stackTrace - Controls stack trace enhancement (Apex/Integration logs only)

  • userInfo - Controls fetching of User name

  • totalActiveSession - Controls fetching of current logged-in user count

  • setAll - Sets all flags to the provided value

Build Method:

public String build()

Returns a JSON string representation of the post-processing controls.

Example:

String controls = new TritonHelper.PostProcessingControlsBuilder()
    .stackTrace(true)
    .userInfo(true)
    .relatedObjects(true)
    .build();

IntegrationWrapper

Wrapper class for integration logs used to create the JSON structure that combines HTTP objects.

Properties:

  • request - Map<String, Object> containing request details

  • response - Map<String, Object> containing response details

This class is primarily used internally by the toJson methods to structure integration log data.

Runtime Information Components

Captures detailed runtime information from Lightning Web Components:

  • Environment details (user agent, platform, language)

  • Performance metrics (page load time, DOM events, paint times)

  • Memory usage statistics

  • Network information (connection type, speed, RTT)

  • Device characteristics (form factor, screen dimensions)

  • Navigation context (pathname, hostname)

PreviousFlowLogNextPostProcessingControlsBuilder

Last updated 2 months ago

Builder class for constructing Pharos post-processing settings. Controls various aspects of log enhancement after creation. You can find a more .

📖
📔
detailed method reference here
RuntimeInfo (in TritonLwc)