UNPKG

@agility/cli

Version:

Agility CLI for working with your content. (Public Beta)

288 lines 9.58 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.LoggingModes = void 0; var state_1 = require("../../../core/state"); var LoggingModes = /** @class */ (function () { function LoggingModes() { } /** * Determine console mode from current state */ LoggingModes.determineMode = function () { var state = (0, state_1.getState)(); // Priority order: useHeadless > useVerbose > default (plain) // Remove blessed from priority order if (state.useHeadless) { return 'headless'; } if (state.useVerbose) { return 'verbose'; } return 'plain'; }; /** * Get logging configuration for a specific mode */ LoggingModes.getConfig = function (mode) { switch (mode) { case 'headless': return { mode: 'headless', shouldLogToFile: true, shouldLogToConsole: false, shouldRedirectToUI: false, shouldShowProgress: false, shouldShowVerboseOutput: false }; case 'verbose': return { mode: 'verbose', shouldLogToFile: true, shouldLogToConsole: true, shouldRedirectToUI: false, shouldShowProgress: true, shouldShowVerboseOutput: true }; // Remove blessed case: // case 'blessed': // return { // mode: 'blessed', // shouldLogToFile: true, // shouldLogToConsole: false, // shouldRedirectToUI: true, // shouldShowProgress: true, // shouldShowVerboseOutput: false // }; case 'plain': default: return { mode: 'plain', shouldLogToFile: true, shouldLogToConsole: true, shouldRedirectToUI: false, shouldShowProgress: true, shouldShowVerboseOutput: false }; } }; /** * Get current logging configuration based on state */ LoggingModes.getCurrentConfig = function () { var mode = this.determineMode(); return this.getConfig(mode); }; /** * Check if current mode supports specific functionality */ LoggingModes.supportsInteractiveUI = function () { // Remove blessed support - no interactive UI now return false; }; LoggingModes.supportsProgressBars = function () { var config = this.getCurrentConfig(); return config.shouldShowProgress; }; LoggingModes.supportsVerboseOutput = function () { var config = this.getCurrentConfig(); return config.shouldShowVerboseOutput; }; LoggingModes.supportsConsoleOutput = function () { var config = this.getCurrentConfig(); return config.shouldLogToConsole; }; LoggingModes.requiresFileLogging = function () { var config = this.getCurrentConfig(); return config.shouldLogToFile; }; LoggingModes.requiresUIRedirection = function () { var config = this.getCurrentConfig(); return config.shouldRedirectToUI; }; /** * Conditional logging based on mode */ LoggingModes.shouldLog = function (logType) { var config = this.getCurrentConfig(); switch (logType) { case 'console': return config.shouldLogToConsole; case 'file': return config.shouldLogToFile; case 'ui': return config.shouldRedirectToUI; case 'progress': return config.shouldShowProgress; case 'verbose': return config.shouldShowVerboseOutput; default: return true; } }; /** * Get mode-specific log format */ LoggingModes.getLogFormat = function (mode) { switch (mode) { case 'headless': return { includeTimestamp: true, includeLevel: true, includeColors: false, includeProgressBars: false }; case 'verbose': return { includeTimestamp: false, includeLevel: false, includeColors: true, includeProgressBars: true }; // Remove blessed case: // case 'blessed': // return { // includeTimestamp: false, // includeLevel: false, // includeColors: true, // includeProgressBars: true // }; case 'plain': default: return { includeTimestamp: false, includeLevel: false, includeColors: true, includeProgressBars: true }; } }; /** * Get current log format */ LoggingModes.getCurrentLogFormat = function () { var mode = this.determineMode(); return this.getLogFormat(mode); }; /** * Check if we should show specific content based on mode */ LoggingModes.shouldShowContent = function (contentType) { var config = this.getCurrentConfig(); var format = this.getCurrentLogFormat(); switch (contentType) { case 'errors': return true; // Always show errors case 'warnings': return true; // Always show warnings case 'info': return config.shouldLogToConsole || config.shouldRedirectToUI; case 'debug': return config.shouldShowVerboseOutput; case 'stats': return config.shouldShowProgress; default: return true; } }; /** * Get mode-specific console method overrides */ LoggingModes.getModeSpecificBehavior = function (mode) { switch (mode) { case 'headless': return { redirectConsole: true, showInlineProgress: false, enableColors: false, bufferedOutput: false }; case 'verbose': return { redirectConsole: false, showInlineProgress: true, enableColors: true, bufferedOutput: false }; // Remove blessed case: // case 'blessed': // return { // redirectConsole: true, // showInlineProgress: true, // enableColors: true, // bufferedOutput: true // }; case 'plain': default: return { redirectConsole: false, showInlineProgress: true, enableColors: true, bufferedOutput: false }; } }; /** * Get current mode-specific behavior */ LoggingModes.getCurrentBehavior = function () { var mode = this.determineMode(); return this.getModeSpecificBehavior(mode); }; /** * Validate state configuration for logging */ LoggingModes.validateLoggingState = function () { var state = (0, state_1.getState)(); var warnings = []; var errors = []; // Check for conflicting modes var modeCount = [ state.useHeadless, state.useVerbose ].filter(Boolean).length; if (modeCount > 1) { warnings.push('Multiple console modes specified, using priority order: headless > verbose'); } // Check for required state values if (!state.rootPath) { errors.push('rootPath is required for file logging'); } if (!state.sourceGuid) { errors.push('sourceGuid is required for logging operations'); } if (!state.locale) { errors.push('locale is required for logging operations'); } return { isValid: errors.length === 0, warnings: warnings, errors: errors }; }; /** * Get mode description for user feedback */ LoggingModes.getModeDescription = function (mode) { switch (mode) { case 'headless': return 'Headless mode - All output redirected to log file only'; case 'verbose': return 'Verbose mode - Full console output with detailed progress information'; // Remove blessed case - no longer supported case 'plain': return 'Plain mode - Standard console output with basic progress information'; default: return 'Unknown mode'; } }; /** * Get current mode description */ LoggingModes.getCurrentModeDescription = function () { var mode = this.determineMode(); return this.getModeDescription(mode); }; return LoggingModes; }()); exports.LoggingModes = LoggingModes; //# sourceMappingURL=logging-modes.js.map