-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: optimize and improve logger
- Loading branch information
1 parent
018e5e6
commit ec1f3f0
Showing
8 changed files
with
53 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
export * from './Application.js'; | ||
export * from './Detector.js'; | ||
export * from './Logger.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
import process from 'node:process'; | ||
import { type Application, Logger } from '#classes'; | ||
import type { Application } from '#classes'; | ||
import { logger } from '#util'; | ||
|
||
export async function run(client: Application) { | ||
if (process.argv.includes('--deploy')) { | ||
await client.deployCommands(); | ||
process.exit(0); | ||
} | ||
Logger.log('Ready!'); | ||
logger.log('Ready!'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
export { default as changelog } from './changelog.json' with { type: 'json' }; | ||
export * from './fetchTags.js'; | ||
export * from './files.js'; | ||
export * as logger from './logger.js'; | ||
export * from './sendable.js'; | ||
export * from './types.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import process from 'node:process'; | ||
import { env } from '#env'; | ||
import { blue, bold, magenta, red, yellow } from 'yoctocolors'; | ||
|
||
const date = new Intl.DateTimeFormat('sv', { | ||
dateStyle: 'short', | ||
timeStyle: 'medium', | ||
hour12: false | ||
}); | ||
|
||
export function debug(...args: unknown[]) { | ||
if (env.NODE_ENV === 'production') { | ||
return; | ||
} | ||
|
||
console.error(bold(magenta(`${date.format()} DEBUG`)), ...args); | ||
} | ||
|
||
export function error(...args: unknown[]) { | ||
console.error(bold(red(`${date.format()} ERROR`)), ...args); | ||
} | ||
|
||
export function fatal(...args: unknown[]) { | ||
console.error(bold(red(`${date.format()} FATAL`)), ...args); | ||
process.exit(1); | ||
} | ||
|
||
export function log(...args: unknown[]) { | ||
console.log(bold(blue(`${date.format()} LOG`)), ...args); | ||
} | ||
|
||
export function warn(...args: unknown[]) { | ||
console.warn(bold(yellow(`${date.format()} WARN`)), ...args); | ||
} |