Skip to content

Commit

Permalink
replaced all console logging with Logger module
Browse files Browse the repository at this point in the history
  • Loading branch information
pavel-karatsiuba authored and kelson42 committed Feb 18, 2023
1 parent 19831db commit e74f451
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import yargs from 'yargs'
import { hideBin } from 'yargs/helpers'
import { parameterDescriptions, requiredParams } from './parameterList.js'
import * as logger from './Logger.js'

import * as mwofflinerLib from './mwoffliner.lib.js'

Expand Down Expand Up @@ -33,6 +34,7 @@ const argv: any = yargs(hideBin(process.argv))
/* ***********************************/

import fs from 'fs'
;(process as any).verbose = argv.verbose

if (argv.osTmpDir) {
const osTmpDir = argv.osTmpDir as string
Expand All @@ -44,7 +46,7 @@ if (argv.osTmpDir) {
throw new Error()
}
} catch {
console.error(`--osTmpDir value [${osTmpDir}] is not valid`)
logger.error(`--osTmpDir value [${osTmpDir}] is not valid`)
process.exit(2)
}
}
Expand All @@ -64,7 +66,7 @@ sanitize_all(argv)
mwofflinerLib
.execute(argv)
.then(() => {
console.info(`Finished running mwoffliner after [${Math.round((Date.now() - execStartTime) / 1000)}s]`)
logger.info(`Finished running mwoffliner after [${Math.round((Date.now() - execStartTime) / 1000)}s]`)
process.exit(0)
})
.catch((err) => {
Expand Down Expand Up @@ -100,9 +102,9 @@ function errorHandler(err: any) {
} catch (err) {
/* NOOP */
}
console.error(`Failed to run mwoffliner after [${Math.round((Date.now() - execStartTime) / 1000)}s]:`, loggableErr)
logger.error(`Failed to run mwoffliner after [${Math.round((Date.now() - execStartTime) / 1000)}s]:`, loggableErr)
if (err && err.message) {
console.error(`\n\n**********\n\n${err.message}\n\n**********\n\n`)
logger.error(`\n\n**********\n\n${err.message}\n\n**********\n\n`)
}
process.exit(2)
}

0 comments on commit e74f451

Please sign in to comment.