Skip to content

Commit

Permalink
fix(config-tools): Added console logging function typings
Browse files Browse the repository at this point in the history
  • Loading branch information
sullivanpj committed Jan 24, 2024
1 parent c55e4d0 commit c20aac4
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 5 deletions.
81 changes: 81 additions & 0 deletions packages/config-tools/declarations.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,84 @@ export { exitWithSuccess };

declare function handleProcess(config?: StormConfig): void;
export { handleProcess };

/**
* Write a message to the console at the `fatal` log level
*
* @param config - The Storm configuration
* @param message - The message to write
*/
declare function writeFatal(config: Partial<StormConfig>, message: string): void;
export { writeFatal };

/**
* Write a message to the console at the `error` log level
*
* @param config - The Storm configuration
* @param message - The message to write
*/
declare function writeError(config: Partial<StormConfig>, message: string): void;
export { writeError };

/**
* Write a message to the console at the `warning` log level
*
* @param config - The Storm configuration
* @param message - The message to write
*/
declare function writeWarning(config: Partial<StormConfig>, message: string): void;
export { writeWarning };

/**
* Write a message to the console at the `info` log level
*
* @param config - The Storm configuration
* @param message - The message to write
*/
declare function writeInfo(config: Partial<StormConfig>, message: string): void;
export { writeInfo };

/**
* Write a message to the console at the `success` log level
*
* @param config - The Storm configuration
* @param message - The message to write
*/
declare function writeSuccess(config: Partial<StormConfig>, message: string): void;
export { writeSuccess };

/**
* Write a message to the console at the `debug` log level
*
* @param config - The Storm configuration
* @param message - The message to write
*/
declare function writeDebug(config: Partial<StormConfig>, message: string): void;
export { writeDebug };

/**
* Write a message to the console at the `trace` log level
*
* @param config - The Storm configuration
* @param message - The message to write
*/
declare function writeTrace(config: Partial<StormConfig>, message: string): void;
export { writeTrace };

/**
* Write a message to the console at the `all` log level
*
* @param config - The Storm configuration
* @param message - The message to write
*/
declare function writeSystem(config: Partial<StormConfig>, message: string): void;
export { writeSystem };

/**
* Get a stopwatch function
*
* @param name - The name of the process
* @returns The stopwatch function
*/
declare function getStopwatch(name: string): () => void;
export { getStopwatch };
10 changes: 5 additions & 5 deletions packages/config-tools/src/utilities/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ ${chalk.bold.hex(config?.colors?.info ? config.colors.info : "#0ea5e9")(">")} ${
`
${chalk.bold.hex(config?.colors?.success ? config.colors.success : "#087f5b")(">")} ${chalk.bold
.bgHex(config?.colors?.success ? config.colors.success : "#087f5b")
.white(" Success ")} ${chalk.hex(
.white(" Success ")} ${chalk.hex(
config?.colors?.success ? config.colors.success : "#087f5b"
)(message)}
`
Expand All @@ -120,7 +120,7 @@ ${chalk.bold.hex(config?.colors?.success ? config.colors.success : "#087f5b")(">
`
${chalk.bold.hex(config?.colors?.primary ? config.colors.primary : "#1fb2a6")(">")} ${chalk.bold
.bgHex(config?.colors?.primary ? config.colors.primary : "#1fb2a6")
.white(" ! Debug ")} ${chalk.hex(
.white(" 🛠 Debug ")} ${chalk.hex(
config?.colors?.primary ? config.colors.primary : "#1fb2a6"
)(message)}
`
Expand All @@ -133,7 +133,7 @@ ${chalk.bold.hex(config?.colors?.primary ? config.colors.primary : "#1fb2a6")(">
`
${chalk.bold.hex(config?.colors?.primary ? config.colors.primary : "#1fb2a6")(">")} ${chalk.bold
.bgHex(config?.colors?.primary ? config.colors.primary : "#1fb2a6")
.white(" ! System ")} ${chalk.hex(
.white(" System ")} ${chalk.hex(
config?.colors?.primary ? config.colors.primary : "#1fb2a6"
)(message)}
`
Expand Down Expand Up @@ -225,9 +225,9 @@ export const getStopwatch = (name: string) => {
const end = process.hrtime(start);
console.info(
chalk.dim(
`⏱️ The${name ? ` ${name}` : ""} process took ${Math.round(
`\n⏱️ The${name ? ` ${name}` : ""} process took ${Math.round(
end[0] * 1000 + end[1] / 1000000
)}ms to complete`
)}ms to complete\n\n`
)
);
};
Expand Down

0 comments on commit c20aac4

Please sign in to comment.