mirror of
https://github.com/cloudmaker97/FS25-Discord-Bot.git
synced 2025-12-06 00:18:34 +00:00
Logging with timestamp, obtaining more details for #6
This commit is contained in:
parent
50d463ac3b
commit
7ded2598b5
3 changed files with 12 additions and 0 deletions
|
|
@ -3,9 +3,15 @@ import Configuration from "./Services/Configuration";
|
|||
import Logging from "./Services/Logging";
|
||||
import DiscordService from "./Services/DiscordEmbed";
|
||||
|
||||
// Create a new logger instance and configuration instance
|
||||
const appLogger = Logging.getLogger();
|
||||
const appConfig: Configuration = new Configuration();
|
||||
|
||||
// Log the application start and version
|
||||
const packageJson = require('../package.json');
|
||||
appLogger.info(`Starting | App: ${packageJson.name} | Version: ${packageJson.version}`);
|
||||
appLogger.info(`----------------------------------------------------`);
|
||||
|
||||
/**
|
||||
* Check if the configuration is valid and exit the application if it is not
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -56,12 +56,14 @@ export default class DiscordEmbed {
|
|||
this.generateEmbedFromStatusFeed(this.serverStatsFeed).then(embedMessage => {
|
||||
if (this.firstMessageId !== null) {
|
||||
(channel as TextChannel).messages.fetch(this.firstMessageId).then(message => {
|
||||
this.appLogger.info(`Message found, editing message with new embed`);
|
||||
message.edit({embeds: [embedMessage]});
|
||||
}).catch(() => {
|
||||
this.appLogger.warn('Message not found, sending new message');
|
||||
sendInitialMessage(embedMessage);
|
||||
});
|
||||
} else {
|
||||
this.appLogger.info(`No message found, sending new message`);
|
||||
sendInitialMessage(embedMessage);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -5,8 +5,12 @@ export default class Logging {
|
|||
return winston.createLogger({
|
||||
level: 'info',
|
||||
format: winston.format.combine(
|
||||
winston.format.timestamp({
|
||||
format: 'YYYY-MM-DD HH:mm:ss'
|
||||
}),
|
||||
winston.format.colorize(),
|
||||
winston.format.simple(),
|
||||
winston.format.printf(info => `${info.timestamp} ${info.level}: ${info.message}`)
|
||||
),
|
||||
transports: [
|
||||
new winston.transports.Console(),
|
||||
|
|
|
|||
Loading…
Reference in a new issue