UNPKG

@posthog/wizard

Version:

The PostHog wizard helps you to configure your project

44 lines 1.57 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.LOG_FILE_PATH = void 0; exports.initLogFile = initLogFile; exports.logToFile = logToFile; exports.debug = debug; exports.enableDebugLogs = enableDebugLogs; const chalk_1 = __importDefault(require("chalk")); const fs_1 = require("fs"); const logging_1 = require("./logging"); const clack_1 = __importDefault(require("./clack")); let debugEnabled = false; exports.LOG_FILE_PATH = '/tmp/posthog-wizard.log'; /** * Initialize the log file with a run header. * Call this at the start of each wizard run. */ function initLogFile() { const header = `\n${'='.repeat(60)}\nPostHog Wizard Run: ${new Date().toISOString()}\n${'='.repeat(60)}\n`; (0, fs_1.appendFileSync)(exports.LOG_FILE_PATH, header); } /** * Log a message to the file at /tmp/posthog-wizard.log. * Always writes regardless of debug flag. */ function logToFile(...args) { const timestamp = new Date().toISOString(); const msg = args.map((a) => (0, logging_1.prepareMessage)(a)).join(' '); (0, fs_1.appendFileSync)(exports.LOG_FILE_PATH, `[${timestamp}] ${msg}\n`); } function debug(...args) { if (!debugEnabled) { return; } const msg = args.map((a) => (0, logging_1.prepareMessage)(a)).join(' '); clack_1.default.log.info(chalk_1.default.dim(msg)); } function enableDebugLogs() { debugEnabled = true; } //# sourceMappingURL=debug.js.map