Exciting Update: Version 1.0.1 is now available, introducing high-performance technical indicators and custom drawing tools. Read more
Version: 1.0.0

Custom console log

The CustomConsoleLog module provides developer logging controls for the BacktestX Chart. It allows developers to easily enable or disable all chart logs in the browser console, and provides wrapper logging methods to maintain clean production environments.

Logging Toggle Configuration

The core logging control is managed via the CONSOLE_LOG constant at the top of the custom-console-log.js file. This boolean flag determines whether chart logs are printed to the browser console.

// custom-console-log.js - Developer logging controller for BacktestX Chart
const CONSOLE_LOG = true; // Set to true to show chart logs in the browser console, or false to hide them

Set this flag to false in production environments to suppress all charting logs and keep the browser console clean.

Console Interception

When CONSOLE_LOG is set to false, the module automatically intercepts the standard browser console methods to prevent any logging output from the chart:

  • console.log: Overridden with an empty function.
  • console.error: Overridden with an empty function.
  • console.warn: Overridden with an empty function.
  • console.info: Overridden with an empty function.
// Capture original console methods
const originalLog = console.log;
const originalError = console.error;
const originalWarn = console.warn;
const originalInfo = console.info;

// Intercept browser console methods if logging is disabled
if (!CONSOLE_LOG) {
  console.log = function() {};
  console.error = function() {};
  console.warn = function() {};
  console.info = function() {};
}

ChartingAPI Logging Wrappers

The module registers custom wrappers under the global window.ChartingAPI object. These wrappers respect the CONSOLE_LOG setting and route messages to the original console methods if logging is enabled:

  • ChartingAPI.log(...args)

    Wrapper for logging general debug messages. Calls originalLog if CONSOLE_LOG is true.

  • ChartingAPI.error(...args)

    Wrapper for logging error messages. Calls originalError if CONSOLE_LOG is true.

// Example usage in charting modules:
window.ChartingAPI.log("🧠 resolveSymbol: BTCUSD | Type=crypto | Scale=100");
window.ChartingAPI.error("❌ Failed to load datafeed");