Logger
The `Logger` class provides structured console logging with prefixes and grouping. All output is gated behind the `debug` config flag — when off, nothing is logged.
import { getLogger } from '@segmentify/integration';
const logger = getLogger();
logger.log('Something happened');logger.info('Info message');logger.warn('Warning');logger.error('Error');All output is prefixed with [Segmentify] by default.
Component Prefixes
Section titled “Component Prefixes”Create scoped loggers for different parts of your code:
const eventsLogger = getLogger().withPrefix('Events');eventsLogger.log('Event sent');// Output: [Segmentify] [Events] Event sentEach withPrefix call creates a new instance — scoped loggers don’t affect each other.
Console Grouping
Section titled “Console Grouping”const logger = getLogger();logger.group('Processing events');logger.log('Event 1 sent');logger.log('Event 2 sent');logger.groupEnd();Runtime Updates
Section titled “Runtime Updates”Toggle debug mode or change the prefix without re-initializing:
import { updateLoggerConfig } from '@segmentify/integration';
updateLoggerConfig({ debug: false });updateLoggerConfig({ debug: true, prefix: '[MyApp]' });Checking Debug State
Section titled “Checking Debug State”if (getLogger().isDebugEnabled()) { getLogger().log('Detailed debug info', expensiveComputation());}