Skip to content
This repository has been archived by the owner on Sep 3, 2024. It is now read-only.

Commit

Permalink
feat: removed source property from logger
Browse files Browse the repository at this point in the history
  • Loading branch information
mariusbegby committed Aug 31, 2023
1 parent 72ae790 commit 9aaba5e
Show file tree
Hide file tree
Showing 37 changed files with 17 additions and 55 deletions.
1 change: 0 additions & 1 deletion src/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { Logger } from 'pino';

const executionId: string = uuidv4();
const logger: Logger = loggerModule.child({
source: 'bot.js',
module: 'shardingClient',
name: 'shardingClient',
executionId: executionId,
Expand Down
1 change: 0 additions & 1 deletion src/events/client/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ module.exports = {
execute: async (message: string) => {
const executionId: string = uuidv4();
const logger: Logger = loggerModule.child({
source: 'debug.js',
module: 'event',
name: 'clientDebug',
executionId: executionId
Expand Down
1 change: 0 additions & 1 deletion src/events/client/disconnect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ module.exports = {
execute: async (client: ExtendedClient) => {
const executionId: string = uuidv4();
const logger: Logger = loggerModule.child({
source: 'disconnect.js',
module: 'event',
name: 'clientDisconnect',
executionId: executionId,
Expand Down
1 change: 0 additions & 1 deletion src/events/client/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ module.exports = {
execute: async (error: Error) => {
const executionId: string = uuidv4();
const logger: Logger = loggerModule.child({
source: 'error.js',
module: 'event',
name: 'clientError',
executionId: executionId
Expand Down
1 change: 0 additions & 1 deletion src/events/client/guildCreate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ module.exports = {
execute: async (guild: Guild) => {
const executionId: string = uuidv4();
const logger: Logger = loggerModule.child({
source: 'guildCreate.js',
module: 'event',
name: 'guildCreate',
executionId: executionId,
Expand Down
1 change: 0 additions & 1 deletion src/events/client/guildDelete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ module.exports = {
execute: async (guild: Guild) => {
const executionId: string = uuidv4();
const logger: Logger = loggerModule.child({
source: 'guildDelete.js',
module: 'event',
name: 'guildDelete',
executionId: executionId,
Expand Down
1 change: 0 additions & 1 deletion src/events/client/ready.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ module.exports = {
execute: async (client: ExtendedClient) => {
const executionId: string = uuidv4();
const logger: Logger = loggerModule.child({
source: 'ready.js',
module: 'event',
name: 'clientReady',
executionId: executionId,
Expand Down
1 change: 0 additions & 1 deletion src/events/client/reconnecting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ module.exports = {
execute: async (client: ExtendedClient) => {
const executionId: string = uuidv4();
const logger: Logger = loggerModule.child({
source: 'reconnecting.js',
module: 'event',
name: 'clientReconnecting',
executionId: executionId,
Expand Down
1 change: 0 additions & 1 deletion src/events/client/warn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ module.exports = {
execute: async (warning: string) => {
const executionId: string = uuidv4();
const logger: Logger = loggerModule.child({
source: 'warn.js',
module: 'event',
name: 'clientWarn',
executionId: executionId
Expand Down
1 change: 0 additions & 1 deletion src/events/interactions/interactionCreate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ module.exports = {
const inputTime: number = new Date().getTime();
const executionId: string = uuidv4();
const logger: Logger = loggerModule.child({
source: 'interactionCreate.js',
module: 'event',
name: 'interactionCreate',
executionId: executionId,
Expand Down
1 change: 0 additions & 1 deletion src/events/player/generalDebug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ module.exports = {
execute: async (message: string) => {
const executionId: string = uuidv4();
const logger: Logger = loggerModule.child({
source: 'generalDebug.js',
module: 'event',
name: 'playerGeneralDebug',
executionId: executionId
Expand Down
1 change: 0 additions & 1 deletion src/events/player/generalError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ module.exports = {
execute: async (queue: ExtendedGuildQueuePlayerNode, error: Error) => {
const executionId: string = uuidv4();
const logger: Logger = loggerModule.child({
source: 'generalError.js',
module: 'event',
name: 'playerGeneralError',
executionId: executionId,
Expand Down
1 change: 0 additions & 1 deletion src/events/player/playerDebug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ module.exports = {
execute: async (message: string) => {
const executionId: string = uuidv4();
const logger: Logger = loggerModule.child({
source: 'playerDebug.js',
module: 'event',
name: 'playerDebug',
executionId: executionId
Expand Down
1 change: 0 additions & 1 deletion src/events/player/playerError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ module.exports = {
execute: async (queue: ExtendedGuildQueuePlayerNode, error: Error) => {
const executionId: string = uuidv4();
const logger: Logger = loggerModule.child({
source: 'playerError.js',
module: 'event',
name: 'playerError',
executionId: executionId,
Expand Down
1 change: 0 additions & 1 deletion src/events/player/playerSkip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ module.exports = {
execute: async (queue: ExtendedGuildQueuePlayerNode, track: Track) => {
const executionId: string = uuidv4();
const logger: Logger = loggerModule.child({
source: 'playerSkip.js',
module: 'event',
name: 'playerSkip',
executionId: executionId,
Expand Down
1 change: 0 additions & 1 deletion src/events/player/playerStart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ module.exports = {
execute: async (queue: ExtendedGuildQueuePlayerNode, track: Track) => {
const executionId: string = uuidv4();
const logger: Logger = loggerModule.child({
source: 'playerStart.js',
module: 'event',
name: 'playerStart',
executionId: executionId,
Expand Down
1 change: 0 additions & 1 deletion src/events/process/uncaughtException.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ module.exports = {
execute: async (error: Error) => {
const executionId: string = uuidv4();
const logger: Logger = loggerModule.child({
source: 'uncaughtException.js',
module: 'event',
name: 'uncaughtException',
executionId: executionId
Expand Down
1 change: 0 additions & 1 deletion src/events/process/unhandledRejection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ module.exports = {
execute: async (error: Error) => {
const executionId: string = uuidv4();
const logger: Logger = loggerModule.child({
source: 'unhandledRejection.js',
module: 'event',
name: 'unhandledRejection',
executionId: executionId
Expand Down
1 change: 0 additions & 1 deletion src/handlers/interactionAutocompleteHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export const handleAutocomplete = async (
) => {
// TODO: Define TS Type for handlers, and require logger constant?
const logger: Logger = loggerModule.child({
source: 'interactionAutocompleteHandler.ts',
module: 'handler',
name: 'interactionAutocompleteHandler',
executionId: executionId
Expand Down
1 change: 0 additions & 1 deletion src/handlers/interactionCommandHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export const handleCommand = async (
interactionIdentifier: string
) => {
const logger: Logger = loggerModule.child({
source: 'interactionCommandHandler.ts',
module: 'handler',
name: 'interactionCommandHandler',
executionId: executionId
Expand Down
1 change: 0 additions & 1 deletion src/handlers/interactionComponentHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export const handleComponent = async (
interactionIdentifier: string
) => {
const logger: Logger = loggerModule.child({
source: 'interactionComponentHandler.js',
module: 'handler',
name: 'interactionComponentHandler',
executionId: executionId
Expand Down
1 change: 0 additions & 1 deletion src/handlers/interactionErrorHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export const handleError = async (
interactionIdentifier: string
) => {
const logger: Logger = loggerModule.child({
source: 'interactionErrorHandler.ts',
module: 'handler',
name: 'interactionErrorHandler',
executionId: executionId
Expand Down
1 change: 0 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ manager.on('shardCreate', (shard: Shard) => {
const executionId: string = uuidv4();

const logger: Logger = loggerModule.child({
source: 'index.js',
module: 'shardingManager',
name: 'shardingManager',
executionId: executionId,
Expand Down
32 changes: 17 additions & 15 deletions src/interactions/commands/system/reload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class ReloadCommand extends BaseSlashCommandInteraction {
constructor() {
const data = new SlashCommandBuilder()
.setName('reload')
.setDescription('Reload all slash commands across shards.');
.setDescription('Reload slash command, autocomplete and component interactions across shards.');
const isSystemCommand: boolean = true;
super(data, isSystemCommand);
}
Expand All @@ -25,7 +25,7 @@ class ReloadCommand extends BaseSlashCommandInteraction {
}

try {
logger.debug('Reloading commands across all shards.');
logger.debug('Reloading interaction module across all shards.');
await client!
.shard!.broadcastEval(
async (shardClient: ExtendedClient, { executionId }) => {
Expand All @@ -34,38 +34,40 @@ class ReloadCommand extends BaseSlashCommandInteraction {
{ context: { executionId: executionId } }
)
.then(() => {
logger.debug('Successfully reloaded commands across all shards.');
logger.debug('Successfully reloaded interaction module across all shards.');
});
} catch (error) {
logger.error(error, 'Failed to reload commands across shards.');
logger.error(error, 'Failed to reload interaction module across shards.');

logger.debug('Responding with error embed.');
return await interaction.editReply({
embeds: [
new EmbedBuilder()

.setDescription(
`**${this.embedOptions.icons.error} Oops!**\n_Hmm.._ It seems I am unable to reload commands across shards.`
`**${this.embedOptions.icons.error} Oops!**\n_Hmm.._ It seems I am unable to reload interaction module across shards.`
)
.setColor(this.embedOptions.colors.error)
.setFooter({ text: `Execution ID: ${executionId}` })
]
});
}

const commands: string[] | undefined = client!.slashCommandInteractions?.map((command: BaseSlashCommandInteraction) => {
let params: string = '';
const commands: string[] | undefined = client!.slashCommandInteractions?.map(
(command: BaseSlashCommandInteraction) => {
let params: string = '';

if (command.data.options && command.data.options.length > 1) {
const options = command.data.options as unknown as ApplicationCommandOptionData[];
if (command.data.options && command.data.options.length > 1) {
const options = command.data.options as unknown as ApplicationCommandOptionData[];

options.map((option: ApplicationCommandOption) => {
params += `**\`${option.name}\`**` + ' ';
});
}
options.map((option: ApplicationCommandOption) => {
params += `**\`${option.name}\`**` + ' ';
});
}

return `- **\`/${command.data.name}\`** ${params}- ${command.data.description}`;
});
return `- **\`/${command.data.name}\`** ${params}- ${command.data.description}`;
}
);

const embedDescription: string =
`**${this.embedOptions.icons.bot} Reloaded commands**\n` + commands?.join('\n');
Expand Down
1 change: 0 additions & 1 deletion src/utils/deploySlashCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ const systemOptions: SystemOptions = config.get('systemOptions');
const executionId: string = uuidv4();

const logger: Logger = loggerModule.child({
source: 'deploySlashCommands.js',
module: 'deploy',
name: 'deploySlashCommands',
executionId: executionId
Expand Down
1 change: 0 additions & 1 deletion src/utils/factory/createClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { Logger } from 'pino';

export const createClient = async ({ executionId }: { executionId: string }) => {
const logger: Logger = loggerModule.child({
source: 'createClient.js',
module: 'utilFactory',
name: 'createClient',
executionId: executionId,
Expand Down
1 change: 0 additions & 1 deletion src/utils/factory/createPlayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { Logger } from 'pino';

export const createPlayer = async ({ client, executionId }: CreatePlayerParams) => {
const logger: Logger = loggerModule.child({
source: 'createPlayer.js',
module: 'utilFactory',
name: 'createPlayer',
executionId: executionId,
Expand Down
1 change: 0 additions & 1 deletion src/utils/other/postBotStats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { ClientRequest, ClientRequestArgs } from 'node:http';

export const postBotStats = async ({ client, executionId }: PostBotStatsParams) => {
const logger: Logger = loggerModule.child({
source: 'postBotStats.js',
module: 'utilOther',
name: 'postBotStats',
executionId: executionId,
Expand Down
1 change: 0 additions & 1 deletion src/utils/other/startLoadTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const loadTestOptions: LoadTestOptions = config.get('loadTestOptions');

export const startLoadTest = async ({ client, executionId }: StartLoadTestParams) => {
const logger: Logger = loggerModule.child({
source: 'startLoadTest.js',
module: 'utilOther',
name: 'startLoadTest',
executionId: executionId,
Expand Down
1 change: 0 additions & 1 deletion src/utils/registerClientInteractions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { ExtendedClient } from '../types/clientTypes';

export const registerClientInteractions = async ({ client, executionId }: RegisterClientInteractionsParams) => {
const logger: Logger = loggerModule.child({
source: 'registerClientInteractions.js',
module: 'register',
name: 'registerClientInteractions',
executionId: executionId,
Expand Down
1 change: 0 additions & 1 deletion src/utils/registerEventListeners.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ const registerPlayerEventListeners = (player: Player, event: CustomEvent, logger

export const registerEventListeners = async ({ client, player, executionId }: RegisterEventListenersParams) => {
const logger: Logger = loggerModule.child({
source: 'registerEventListeners.js',
module: 'register',
name: 'registerEventListeners',
executionId: executionId,
Expand Down
1 change: 0 additions & 1 deletion src/utils/system/getUptimeFormatted.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { GetUptimeFormattedParams } from '../../types/utilTypes';

export const getUptimeFormatted = async ({ executionId }: GetUptimeFormattedParams) => {
const logger: Logger = loggerModule.child({
source: 'getUptimeFormatted.js',
module: 'utilSystem',
name: 'getUptimeFormatted',
executionId: executionId
Expand Down
2 changes: 0 additions & 2 deletions src/utils/validation/permissionValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import { CannotJoinVoiceOrTalkParams, CannotSendMessageInChannelParams } from '.
const embedOptions: EmbedOptions = config.get('embedOptions');
export const cannotJoinVoiceOrTalk = async ({ interaction, executionId }: CannotJoinVoiceOrTalkParams) => {
const logger: Logger = loggerModule.child({
source: 'permissionValidator.js',
module: 'utilValidation',
name: 'cannotJoinVoiceOrTalk',
executionId: executionId,
Expand Down Expand Up @@ -52,7 +51,6 @@ export const cannotJoinVoiceOrTalk = async ({ interaction, executionId }: Cannot

export const cannotSendMessageInChannel = async ({ interaction, executionId }: CannotSendMessageInChannelParams) => {
const logger: Logger = loggerModule.child({
source: 'permissionValidator.js',
module: 'utilValidation',
name: 'cannotSendMessageInChannel',
executionId: executionId,
Expand Down
3 changes: 0 additions & 3 deletions src/utils/validation/queueValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { Logger } from 'pino';
const embedOptions: EmbedOptions = config.get('embedOptions');
export const queueDoesNotExist = async ({ interaction, queue, executionId }: QueueDoesNotExistParams) => {
const logger: Logger = loggerModule.child({
source: 'queueValidator.js',
module: 'utilValidation',
name: 'queueDoesNotExist',
executionId: executionId,
Expand Down Expand Up @@ -40,7 +39,6 @@ export const queueDoesNotExist = async ({ interaction, queue, executionId }: Que

export const queueNoCurrentTrack = async ({ interaction, queue, executionId }: QueueNoCurrentTrackParams) => {
const logger: Logger = loggerModule.child({
source: 'queueValidator.js',
module: 'utilValidation',
name: 'queueNoCurrentTrack',
executionId: executionId,
Expand Down Expand Up @@ -71,7 +69,6 @@ export const queueNoCurrentTrack = async ({ interaction, queue, executionId }: Q

export const queueIsEmpty = async ({ interaction, queue, executionId }: QueueIsEmptyParams) => {
const logger: Logger = loggerModule.child({
source: 'queueValidator.js',
module: 'utilValidation',
name: 'queueIsEmpty',
executionId: executionId,
Expand Down
1 change: 0 additions & 1 deletion src/utils/validation/searchQueryValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { TransformQueryParams } from '../../types/utilTypes';

export const transformQuery = async ({ query, executionId }: TransformQueryParams) => {
const logger: Logger = loggerModule.child({
source: 'searchQueryValidator.js',
module: 'utilValidation',
name: 'transformQuery',
executionId: executionId
Expand Down
1 change: 0 additions & 1 deletion src/utils/validation/systemCommandValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const embedOptions: EmbedOptions = config.get('embedOptions');
const systemOptions: SystemOptions = config.get('systemOptions');
export const notValidGuildId = async ({ interaction, executionId }: NotValidGuildIdParams) => {
const logger: Logger = loggerModule.child({
source: 'systemCommandValidator.js',
module: 'utilValidation',
name: 'notValidGuildId',
executionId: executionId,
Expand Down
2 changes: 0 additions & 2 deletions src/utils/validation/voiceChannelValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { NotInSameVoiceChannelParams, NotInVoiceChannelParams } from '../../type
const embedOptions: EmbedOptions = config.get('embedOptions');
export const notInVoiceChannel = async ({ interaction, executionId }: NotInVoiceChannelParams) => {
const logger: Logger = loggerModule.child({
source: 'voiceChannelValidator.js',
module: 'validator',
name: 'notInVoiceChannel',
executionId: executionId,
Expand Down Expand Up @@ -40,7 +39,6 @@ export const notInVoiceChannel = async ({ interaction, executionId }: NotInVoice

export const notInSameVoiceChannel = async ({ interaction, queue, executionId }: NotInSameVoiceChannelParams) => {
const logger: Logger = loggerModule.child({
source: 'voiceChannelValidator.js',
module: 'utilValidation',
name: 'notInSameVoiceChannel',
executionId: executionId,
Expand Down

0 comments on commit 9aaba5e

Please sign in to comment.