UNPKG

@storm-software/config-tools

Version:

A package containing various utilities to support custom workspace configurations and environment management for Storm Software projects, including configuration file handling, environment variable management, and logging utilities.

125 lines (122 loc) 4.59 kB
import { StormWorkspaceConfig } from '@storm-software/config'; import { LogLevel } from '../types.cjs'; import { getChalk } from './chalk.cjs'; interface GetLogFnOptions { /** * Whether to include the full date and time in the log message (defaults to `false`, which only includes the time) * * @defaultValue false */ fullDateTime?: boolean; /** * Whether to hide the date and time in the log message (defaults to `false`, which includes the date and time based on the `fullDateTime` option) * * @defaultValue false */ hideDateTime?: boolean; /** * The color configuration to use for the log message (defaults to the default Storm color configuration) */ chalk?: ReturnType<typeof getChalk>; } /** * Get the log function for a log level * * @param logLevel - The log level * @param config - The Storm configuration * @returns The log function */ declare const getLogFn: (logLevel?: number | LogLevel, config?: Partial<StormWorkspaceConfig>, options?: GetLogFnOptions) => ((message?: any) => void); /** * Write a message to the console at the `fatal` log level * * @param message - The message to write * @param config - The Storm configuration */ declare const writeFatal: (message?: any, config?: Partial<StormWorkspaceConfig>) => void; /** * Write a message to the console at the `error` log level * * @param message - The message to write * @param config - The Storm configuration */ declare const writeError: (message?: any, config?: Partial<StormWorkspaceConfig>) => void; /** * Write a message to the console at the `warning` log level * * @param message - The message to write * @param config - The Storm configuration */ declare const writeWarning: (message?: any, config?: Partial<StormWorkspaceConfig>) => void; /** * Write a message to the console at the `info` log level * * @param message - The message to write * @param config - The Storm configuration */ declare const writeInfo: (message?: any, config?: Partial<StormWorkspaceConfig>) => void; /** * Write a message to the console at the `success` log level * * @param message - The message to write * @param config - The Storm configuration */ declare const writeSuccess: (message?: any, config?: Partial<StormWorkspaceConfig>) => void; /** * Write a message to the console at the `performance` log level * * @param message - The message to write * @param config - The Storm configuration */ declare const writePerformance: (message?: any, config?: Partial<StormWorkspaceConfig>) => void; /** * Write a message to the console at the `debug` log level * * @param message - The message to write * @param config - The Storm configuration */ declare const writeDebug: (message?: any, config?: Partial<StormWorkspaceConfig>) => void; /** * Write a message to the console at the `trace` log level * * @param message - The message to write * @param config - The Storm configuration */ declare const writeTrace: (message?: any, config?: Partial<StormWorkspaceConfig>) => void; /** * Write a message to the console at the `all` log level * * @param message - The message to write * @param config - The Storm configuration */ declare const writeSystem: (message?: any, config?: Partial<StormWorkspaceConfig>) => void; /** * Get a stopwatch function * * @param name - The name of the process * @returns The stopwatch function */ declare const getStopwatch: (name: string) => () => void; type FormatLogMessageOptions = { prefix?: string; skip?: string[]; sort?: boolean; }; /** * Format a log message for output to the console, handling different types of messages (e.g. strings, objects, arrays) and applying formatting options such as prefixing and skipping certain keys in objects. * * @param message - The message to format * @param options - Formatting options * @param depth - The current depth of recursion * @returns The formatted log message */ declare const formatLogMessage: (message?: any, options?: FormatLogMessageOptions, depth?: number) => string; /** * Get the brand icon for the console * * @param config - The Storm configuration * @param _chalk - The chalk instance * @returns The brand icon */ declare const brandIcon: (config?: Partial<StormWorkspaceConfig>, _chalk?: ReturnType<typeof getChalk>) => string | undefined; export { type FormatLogMessageOptions, type GetLogFnOptions, brandIcon, formatLogMessage, getLogFn, getStopwatch, writeDebug, writeError, writeFatal, writeInfo, writePerformance, writeSuccess, writeSystem, writeTrace, writeWarning };