fix!: fixed logging service not logging to file, removed app-info log file.

This commit is contained in:
Marius Begby committed 2023-08-28 18:23:12 +02:00
1 parent 780e20d419
commit 92a535d837
4 files changed
+15 -20

No files matched your search

+1 -1
View File
@@ -34,7 +34,6 @@ module.exports = {
logger.debug('Interaction received.'); logger.debug('Interaction received.');
let interactionIdentifier = 'Unknown'; let interactionIdentifier = 'Unknown';
if ( if (
interaction.type === InteractionType.ApplicationCommand || interaction.type === InteractionType.ApplicationCommand ||
interaction.type === InteractionType.ApplicationCommandAutocomplete interaction.type === InteractionType.ApplicationCommandAutocomplete
@@ -73,6 +72,7 @@ module.exports = {
const outputTime: number = new Date().getTime(); const outputTime: number = new Date().getTime();
const executionTime: number = outputTime - inputTime; const executionTime: number = outputTime - inputTime;
const interactionType = InteractionType[interaction.type]; const interactionType = InteractionType[interaction.type];
logger.info( logger.info(
+6 -13
View File
@@ -9,28 +9,19 @@ const loggerOptions: LoggerOptions = config.get('loggerOptions');
const targets: TargetOptions[] = [ const targets: TargetOptions[] = [
{ {
// This target is used for logging everything above specified minimumLogLevel
target: 'pino/file', target: 'pino/file',
level: loggerOptions.minimumLogLevel, level: loggerOptions.minimumLogLevel,
options: { options: {
destination: './logs/app-all.log', destination: './logs/app-all.log',
mkdir: true, mkdir: true,
sync: false, sync: false
minLength: 4096
} }
}, },
{ {
// This target is used for logging errors separately
target: 'pino/file', target: 'pino/file',
level: pino.levels.values.info.toString(), level: 'error',
options: {
destination: './logs/app-info.log',
mkdir: true,
sync: false,
minLength: 4096
}
},
{
target: 'pino/file',
level: pino.levels.values.error.toString(),
options: { options: {
destination: './logs/app-error.log', destination: './logs/app-error.log',
mkdir: true, mkdir: true,
@@ -38,6 +29,7 @@ const targets: TargetOptions[] = [
} }
}, },
{ {
// This target is used for logging to the console
target: 'pino/file', target: 'pino/file',
level: loggerOptions.minimumLogLevelConsole, level: loggerOptions.minimumLogLevelConsole,
options: { options: {
@@ -57,6 +49,7 @@ if (process.env.LOKI_AUTH_PASSWORD && process.env.LOKI_AUTH_USERNAME) {
batching: false, batching: false,
interval: 5, interval: 5,
// Loki host and credentials are retrieved from environment variables
host: process.env.LOKI_HOST || 'http://localhost:3100', host: process.env.LOKI_HOST || 'http://localhost:3100',
basicAuth: { basicAuth: {
username: process.env.LOKI_AUTH_USERNAME || '', username: process.env.LOKI_AUTH_USERNAME || '',
+5 -5
View File
@@ -1,6 +1,6 @@
import { import { ActivityType, ColorResolvable, PresenceUpdateStatus, ShardingManagerOptions } from 'discord.js';
ActivityType, ColorResolvable, PresenceUpdateStatus, ShardingManagerOptions
} from 'discord.js'; import { LogLevel } from './serviceTypes';
export interface BotOptions { export interface BotOptions {
name: string; name: string;
@@ -11,8 +11,8 @@ export interface BotOptions {
export interface ShardingOptions extends ShardingManagerOptions {} export interface ShardingOptions extends ShardingManagerOptions {}
export interface LoggerOptions { export interface LoggerOptions {
minimumLogLevel: string; minimumLogLevel: LogLevel;
minimumLogLevelConsole: string; minimumLogLevelConsole: LogLevel;
discordPlayerDebug: boolean; discordPlayerDebug: boolean;
} }
+3 -1
View File
@@ -1,6 +1,8 @@
export type LogLevel = 'fatal' | 'error' | 'warn' | 'info' | 'debug' | 'trace' | 'silent';
export type TargetOptions = { export type TargetOptions = {
target: string; target: string;
level: string; level: LogLevel;
options: { options: {
destination?: string; destination?: string;
mkdir?: boolean; mkdir?: boolean;