import { ServiceNowInstance } from "../ServiceNowInstance.js"; import { SyslogRecord, SyslogAppScopeRecord, SyslogFormatOptions, SyslogTailOptions } from './SyslogRecord.js'; /** * SyslogReader class for querying and tailing ServiceNow syslog tables * Supports encoded query strings, formatted table output, and file export */ export declare class SyslogReader { private readonly SYSLOG_TABLE; private readonly SYSLOG_APP_SCOPE_TABLE; private _logger; private _tableAPI; private _processorRequest; private _instance; private _tailInterval?; private _lastFetchedSysId?; private _lastSequence?; private _isTailing; constructor(instance: ServiceNowInstance); /** * Query the syslog table with an encoded query string * @param encodedQuery ServiceNow encoded query string (e.g., "levelSTARTSWITHerror^ORDERBYDESCsys_created_on") * @param limit Maximum number of records to return (default: 100) * @returns Promise Array of syslog records */ querySyslog(encodedQuery?: string, limit?: number): Promise; /** * Query the syslog_app_scope table with an encoded query string * @param encodedQuery ServiceNow encoded query string * @param limit Maximum number of records to return (default: 100) * @returns Promise Array of syslog_app_scope records */ querySyslogAppScope(encodedQuery?: string, limit?: number): Promise; /** * Format syslog records as a table for console output * @param records Array of syslog records * @param options Formatting options * @returns string Formatted table as string */ formatAsTable(records: (SyslogRecord | SyslogAppScopeRecord)[], options?: SyslogFormatOptions): string; /** * Build ASCII table from rows * @param rows Array of row data * @param colWidths Column widths * @param hasHeader Whether first row is header * @returns Formatted table string */ private buildAsciiTable; /** * Pad string to specified width * @param str String to pad * @param width Target width * @returns Padded string */ private padString; /** * Format and print syslog records to console * @param records Array of syslog records * @param options Formatting options */ printTable(records: (SyslogRecord | SyslogAppScopeRecord)[], options?: SyslogFormatOptions): void; /** * Save syslog records to a file * @param records Array of syslog records * @param filePath Path to save the file * @param format Output format ('json', 'csv', 'table') * @param append Whether to append to existing file (default: false) */ saveToFile(records: (SyslogRecord | SyslogAppScopeRecord)[], filePath: string, format?: 'json' | 'csv' | 'table', append?: boolean): Promise; /** * Tail syslog in real-time (like tail -f) * @param tableName Table to tail ('syslog' or 'syslog_app_scope') * @param options Tail options including query, interval, and callbacks */ startTailing(tableName?: 'syslog' | 'syslog_app_scope', options?: SyslogTailOptions): Promise; /** * Tail ServiceNow logs using the ChannelAjax logtail processor * This is more efficient than polling the table API as it uses sequence numbers * @param options Tail options including interval and callbacks */ startTailingWithChannelAjax(options?: Omit): Promise; /** * Fetch logs from the ChannelAjax logtail processor * @returns Array of log tail items */ private fetchLogsFromChannelAjax; /** * Parse XML response from ChannelAjax logtail * @param xmlData XML string from response * @returns Parsed LogTailResponse */ private parseLogTailXml; /** * Format a LogTailItem for console output * @param item Log tail item * @returns Formatted string */ private formatLogTailItem; /** * Convert LogTailItem to SyslogRecord format * @param item Log tail item * @returns SyslogRecord */ private logTailItemToSyslogRecord; /** * Save text content to a file * @param content Text content to save * @param filePath File path * @param append Whether to append */ private saveTextToFile; /** * Stop tailing logs */ stopTailing(): void; /** * Check if currently tailing */ get isTailing(): boolean; /** * Format records as CSV * @param records Array of records * @returns CSV string */ private formatAsCSV; /** * Format date based on format option * @param dateString ISO date string * @param format Date format option * @returns Formatted date string */ private formatDate; /** * Get relative time string (e.g., "2 minutes ago") * @param date Date object * @returns Relative time string */ private getRelativeTime; /** * Colorize log level for console output * @param level Log level * @returns Colorized level string */ private colorizeLevel; /** * Truncate string to maximum length * @param str String to truncate * @param maxLength Maximum length * @returns Truncated string */ private truncateString; }