diff options
author | 2021-04-01 10:25:28 -0600 | |
---|---|---|
committer | 2021-04-01 10:25:28 -0600 | |
commit | c26c244ca2634d462616d6cf71072fbe26becba2 (patch) | |
tree | 1bd5e83eff9ca88200aacb272c84439f192015ec /src/logger.ts | |
parent | f6a7ac67befff863e34133673efb78ea7ac0fe48 (diff) | |
download | astro-c26c244ca2634d462616d6cf71072fbe26becba2.tar.gz astro-c26c244ca2634d462616d6cf71072fbe26becba2.tar.zst astro-c26c244ca2634d462616d6cf71072fbe26becba2.zip |
Annoying Lint PR #2 (#47)
Diffstat (limited to 'src/logger.ts')
-rw-r--r-- | src/logger.ts | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/logger.ts b/src/logger.ts index 6634c5092..7ffc2da5a 100644 --- a/src/logger.ts +++ b/src/logger.ts @@ -61,6 +61,7 @@ const levels: Record<LoggerLevel, number> = { silent: 90, }; +/** Full logging API */ export function log(opts: LogOptions = defaultLogOptions, level: LoggerLevel, type: string, ...args: Array<any>) { const event: LogMessage = { type, @@ -77,22 +78,27 @@ export function log(opts: LogOptions = defaultLogOptions, level: LoggerLevel, ty opts.dest.write(event); } +/** Emit a message only shown in debug mode */ export function debug(opts: LogOptions, type: string, ...messages: Array<any>) { return log(opts, 'debug', type, ...messages); } +/** Emit a general info message (be careful using this too much!) */ export function info(opts: LogOptions, type: string, ...messages: Array<any>) { return log(opts, 'info', type, ...messages); } +/** Emit a warning a user should be aware of */ export function warn(opts: LogOptions, type: string, ...messages: Array<any>) { return log(opts, 'warn', type, ...messages); } +/** Emit a fatal error message the user should address. */ export function error(opts: LogOptions, type: string, ...messages: Array<any>) { return log(opts, 'error', type, ...messages); } +/** Pretty format error for display */ export function parseError(opts: LogOptions, err: CompileError) { let frame = err.frame // Switch colons for pipes @@ -108,7 +114,7 @@ export function parseError(opts: LogOptions, err: CompileError) { ` ${underline(bold(grey(`${err.filename}:${err.start.line}:${err.start.column}`)))} - + ${bold(red(`𝘅 ${err.message}`))} ${frame} |