Compare commits

..

2 commits

Author SHA1 Message Date
f812185937 Fix linting issues
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/pr/woodpecker Pipeline was successful
ci/woodpecker/pull_request_closed/woodpecker Pipeline was successful
2024-03-13 18:04:18 +00:00
7a17c1685e Create configurable log level 2024-03-13 18:03:48 +00:00
5 changed files with 25 additions and 21 deletions

View file

@ -12,7 +12,7 @@ BOT_AUTHOR=Vylpes
BOT_OWNERID=147392775707426816
BOT_CLIENTID=682942374040961060
BOT_ENV=4
BOT_VERBOSE=false
BOT_LOGLEVEL=info
BOT_ADMINS=147392775707426816,887272961504071690
ABOUT_FUNDING=

View file

@ -12,7 +12,7 @@ BOT_AUTHOR=Vylpes
BOT_OWNERID=147392775707426816
BOT_CLIENTID=1093810443589529631
BOT_ENV=1
BOT_VERBOSE=false
BOT_LOGLEVEL=info
BOT_ADMINS=147392775707426816,887272961504071690
ABOUT_FUNDING=

View file

@ -12,7 +12,7 @@ BOT_AUTHOR=Vylpes
BOT_OWNERID=147392775707426816
BOT_CLIENTID=1147976642942214235
BOT_ENV=2
BOT_VERBOSE=false
BOT_LOGLEVEL=info
BOT_ADMINS=147392775707426816,887272961504071690
ABOUT_FUNDING=

View file

@ -12,16 +12,16 @@ export default class AppLogger {
level: logLevel,
format: format.combine(
format.timestamp({
format: 'YYYY-MM-DD HH:mm:ss'
format: "YYYY-MM-DD HH:mm:ss"
}),
format.errors({ stack: true }),
format.splat(),
customFormat,
),
defaultMeta: { service: 'bot' },
defaultMeta: { service: "bot" },
transports: [
new transports.File({ filename: 'error.log', level: 'error' }),
new transports.File({ filename: 'combined.log' }),
new transports.File({ filename: "error.log", level: "error" }),
new transports.File({ filename: "combined.log" }),
],
});
@ -31,10 +31,12 @@ export default class AppLogger {
format.colorize(),
format.timestamp(),
customFormat,
)}));
)}));
}
AppLogger.Logger = logger;
AppLogger.LogInfo("AppLogger", `Log Level: ${logLevel}`);
}
public static LogError(label: string, message: string) {

View file

@ -47,7 +47,9 @@ export class CoreClient extends Client {
CoreClient.Environment = Number(process.env.BOT_ENV);
AppLogger.InitialiseLogger(process.env.BOT_VERBOSE == "true" ? "verbose" : "info", CoreClient.Environment == Environment.Local);
const loglevel = process.env.BOT_LOGLEVEL ?? "info";
AppLogger.InitialiseLogger(loglevel, CoreClient.Environment == Environment.Local);
AppLogger.LogInfo("Client", "Initialising Client");
@ -125,7 +127,7 @@ export class CoreClient extends Client {
};
}
AppLogger.LogVerbose("Client", `Registered Channel Create Event`);
AppLogger.LogVerbose("Client", "Registered Channel Create Event");
}
public static RegisterChannelDeleteEvent(fn: (channel: DMChannel | NonThreadGuildBasedChannel) => void) {
@ -148,7 +150,7 @@ export class CoreClient extends Client {
};
}
AppLogger.LogVerbose("Client", `Registered Channel Delete Event`);
AppLogger.LogVerbose("Client", "Registered Channel Delete Event");
}
public static RegisterChannelUpdateEvent(fn: (channel: DMChannel | NonThreadGuildBasedChannel) => void) {
@ -171,7 +173,7 @@ export class CoreClient extends Client {
};
}
AppLogger.LogVerbose("Client", `Registered Channel Update Event`);
AppLogger.LogVerbose("Client", "Registered Channel Update Event");
}
public static RegisterGuildBanAddEvent(fn: (ban: GuildBan) => void) {
@ -194,7 +196,7 @@ export class CoreClient extends Client {
};
}
AppLogger.LogVerbose("Client", `Registered Guild Ban Add Event`);
AppLogger.LogVerbose("Client", "Registered Guild Ban Add Event");
}
public static RegisterGuildBanRemoveEvent(fn: (channel: GuildBan) => void) {
@ -217,7 +219,7 @@ export class CoreClient extends Client {
};
}
AppLogger.LogVerbose("Client", `Registered Guild Ban Remove Event`);
AppLogger.LogVerbose("Client", "Registered Guild Ban Remove Event");
}
public static RegisterGuildCreateEvent(fn: (guild: Guild) => void) {
@ -240,7 +242,7 @@ export class CoreClient extends Client {
};
}
AppLogger.LogVerbose("Client", `Registered Guild Create Event`);
AppLogger.LogVerbose("Client", "Registered Guild Create Event");
}
public static RegisterGuildMemberAddEvent(fn: (member: GuildMember) => void) {
@ -263,7 +265,7 @@ export class CoreClient extends Client {
};
}
AppLogger.LogVerbose("Client", `Registered Guild Member Add Event`);
AppLogger.LogVerbose("Client", "Registered Guild Member Add Event");
}
public static RegisterGuildMemberRemoveEvent(fn: (member: GuildMember | PartialGuildMember) => void) {
@ -286,7 +288,7 @@ export class CoreClient extends Client {
};
}
AppLogger.LogVerbose("Client", `Registered Guild Member Remove Event`);
AppLogger.LogVerbose("Client", "Registered Guild Member Remove Event");
}
public static GuildMemebrUpdate(fn: (oldMember: GuildMember | PartialGuildMember, newMember: GuildMember) => void) {
@ -309,7 +311,7 @@ export class CoreClient extends Client {
};
}
AppLogger.LogVerbose("Client", `Registered Guild Member Update Event`);
AppLogger.LogVerbose("Client", "Registered Guild Member Update Event");
}
public static RegisterMessageCreateEvent(fn: (message: Message<boolean>) => void) {
@ -332,7 +334,7 @@ export class CoreClient extends Client {
};
}
AppLogger.LogVerbose("Client", `Registered Message Create Event`);
AppLogger.LogVerbose("Client", "Registered Message Create Event");
}
public static RegisterMessageDeleteEvent(fn: (message: Message<boolean> | PartialMessage) => void) {
@ -355,7 +357,7 @@ export class CoreClient extends Client {
};
}
AppLogger.LogVerbose("Client", `Registered Message Delete Event`);
AppLogger.LogVerbose("Client", "Registered Message Delete Event");
}
public static RegisterMessageUpdateEvent(fn: (oldMessage: Message<boolean> | PartialMessage, newMessage: Message<boolean> | PartialMessage) => void) {
@ -378,7 +380,7 @@ export class CoreClient extends Client {
};
}
AppLogger.LogVerbose("Client", `Registered Message Update Event`);
AppLogger.LogVerbose("Client", "Registered Message Update Event");
}
public static RegisterButtonEvent(buttonId: string, event: ButtonEvent, environment: Environment = Environment.All) {