Skip to content

Commit

Permalink
Fixed bug where it would log "null" to console
Browse files Browse the repository at this point in the history
  • Loading branch information
whizbangpop committed Nov 29, 2022
1 parent 055e924 commit 7d4c7bb
Showing 1 changed file with 26 additions and 8 deletions.
34 changes: 26 additions & 8 deletions src/lib/tsabLogger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,11 @@ export async function debug(message: string, options?: OptionsInt) {
fs.appendFile(
getLogFile(),
`${moment().format()} DEBUG | ${message}\n`,
(err) => console.error(err)
(err) => {
if (err) {
console.error(err)
}
}
)

if (sendWebhook) {
Expand All @@ -81,10 +85,16 @@ export async function log(message: string, options?: OptionsInt) {
)} | ${chalk.white(message)}\n`

process.stdout.write(
`${moment().format()} ${chalk.green("LOG")} | ${chalk.white(message)}\n`
`${moment().format()} ${chalk.green("LOG")} | ${chalk.white(message)}\n`
)
fs.appendFile(getLogFile(), `${moment().format()} LOG | ${message}\n`, (err) =>
console.error(err)
fs.appendFile(
getLogFile(),
`${moment().format()} LOG | ${message}\n`,
(err) => {
if (err) {
console.error(err)
}
}
)

if (sendWebhook) {
Expand All @@ -103,12 +113,16 @@ export async function warn(message: string, options?: OptionsInt) {
)} | ${chalk.white(message)}\n`

process.stdout.write(
`${moment().format()} ${chalk.yellow("WARN")} | ${chalk.white(message)}\n`
`${moment().format()} ${chalk.yellow("WARN")} | ${chalk.white(message)}\n`
)
fs.appendFile(
getLogFile(),
`${moment().format()} "WARN" | ${message}\n`,
(err) => console.error(err)
`${moment().format()} "WARN" | ${message}\n`,
(err) => {
if (err) {
console.error(err)
}
}
)

if (sendWebhook) {
Expand All @@ -134,7 +148,11 @@ export async function error(message: string, options?: OptionsInt) {
fs.appendFile(
getLogFile(),
`${moment().format()} ERROR | ${message}\n`,
(err) => console.error(err)
(err) => {
if (err) {
console.error(err)
}
}
)

if (sendWebhook) {
Expand Down

0 comments on commit 7d4c7bb

Please sign in to comment.