17 lines
650 B
TypeScript
17 lines
650 B
TypeScript
// Helper function for padding strings
|
|
export function pad(str: string, length: number): string {
|
|
return str.length > length
|
|
? str.substring(0, length - 3) + '...'
|
|
: str.padEnd(length);
|
|
}
|
|
|
|
// Helper for unknown errors
|
|
export const unknownError = (err: any) =>
|
|
(err?.message && typeof err.message === 'string') ? err.message : String(err);
|
|
|
|
// Helper function to format log entries
|
|
export function formatLog(log: any): string {
|
|
const timestamp = new Date(log.timestamp).toLocaleTimeString();
|
|
const prefix = log.type === 'stdout' ? '[OUT]' : log.type === 'stderr' ? '[ERR]' : '[SYS]';
|
|
return `${timestamp} ${prefix} ${log.message}`;
|
|
} |