aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts/parse-log.ts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/parse-log.ts')
-rwxr-xr-xscripts/parse-log.ts10
1 files changed, 6 insertions, 4 deletions
diff --git a/scripts/parse-log.ts b/scripts/parse-log.ts
index 045348e86..3679dab74 100755
--- a/scripts/parse-log.ts
+++ b/scripts/parse-log.ts
@@ -17,6 +17,8 @@ program
17 .option('-f, --files [file...]', 'Files to parse. If not provided, the script will parse the latest log file from config)') 17 .option('-f, --files [file...]', 'Files to parse. If not provided, the script will parse the latest log file from config)')
18 .parse(process.argv) 18 .parse(process.argv)
19 19
20const options = program.opts()
21
20const excludedKeys = { 22const excludedKeys = {
21 level: true, 23 level: true,
22 message: true, 24 message: true,
@@ -38,7 +40,7 @@ const loggerFormat = winston.format.printf((info) => {
38 if (CONFIG.LOG.PRETTIFY_SQL) { 40 if (CONFIG.LOG.PRETTIFY_SQL) {
39 additionalInfos += '\n' + sqlFormat(info.sql, { 41 additionalInfos += '\n' + sqlFormat(info.sql, {
40 language: 'sql', 42 language: 'sql',
41 ident: ' ' 43 indent: ' '
42 }) 44 })
43 } else { 45 } else {
44 additionalInfos += ' - ' + info.sql 46 additionalInfos += ' - ' + info.sql
@@ -51,7 +53,7 @@ const loggerFormat = winston.format.printf((info) => {
51const logger = winston.createLogger({ 53const logger = winston.createLogger({
52 transports: [ 54 transports: [
53 new winston.transports.Console({ 55 new winston.transports.Console({
54 level: program['level'] || 'debug', 56 level: options.level || 'debug',
55 stderrLevels: [], 57 stderrLevels: [],
56 format: winston.format.combine( 58 format: winston.format.combine(
57 winston.format.splat(), 59 winston.format.splat(),
@@ -76,7 +78,7 @@ run()
76 .catch(err => console.error(err)) 78 .catch(err => console.error(err))
77 79
78function run () { 80function run () {
79 return new Promise(async res => { 81 return new Promise<void>(async res => {
80 const files = await getFiles() 82 const files = await getFiles()
81 83
82 for (const file of files) { 84 for (const file of files) {
@@ -114,7 +116,7 @@ async function getNewestFile (files: string[], basePath: string) {
114} 116}
115 117
116async function getFiles () { 118async function getFiles () {
117 if (program['files']) return program['files'] 119 if (options.files) return options.files
118 120
119 const logFiles = await readdir(CONFIG.STORAGE.LOG_DIR) 121 const logFiles = await readdir(CONFIG.STORAGE.LOG_DIR)
120 122