-
Notifications
You must be signed in to change notification settings - Fork 9
/
index.ts
47 lines (39 loc) · 1.03 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import log4js from 'log4js';
import BotConfig from './src/BotConfig.js';
import MojiraBot from './src/MojiraBot.js';
log4js.configure( {
appenders: {
console: { type: 'console' },
},
categories: {
default: { appenders: ['console'], level: 'info' },
},
} );
try {
BotConfig.init();
const logConfig: log4js.Configuration = {
appenders: {
out: { type: 'stdout' },
},
categories: {
default: { appenders: [ 'out' ], level: BotConfig.debug ? 'debug' : 'info' },
},
};
if ( BotConfig.logDirectory ) {
logConfig.appenders.log = {
type: 'file',
filename: `${ BotConfig.logDirectory }/${ new Date().toJSON().replace( /[:.]/g, '_' ) }.log`,
};
logConfig.categories.default.appenders.push( 'log' );
}
log4js.configure( logConfig );
if ( BotConfig.debug ) {
MojiraBot.logger.info( 'Debug mode is activated' );
}
if ( BotConfig.logDirectory ) {
MojiraBot.logger.info( `Writing log to ${ logConfig.appenders.log[ 'filename' ] }` );
}
await MojiraBot.start();
} catch ( err ) {
MojiraBot.logger.error( err );
}