feat: Add config source to startup logging #309

This commit is contained in:
FoxxMD
2025-07-01 19:33:10 +00:00
parent 8dd6fc15cc
commit a9c1c7083d
2 changed files with 12 additions and 11 deletions
+6 -6
View File
@@ -292,7 +292,7 @@ ${sources.join('\n')}`);
try {
await this.addClient(c, clientDefaults, notifier);
} catch(e) {
const addError = new Error(`Client ${c.name} was not added because it had unrecoverable errors`, {cause: e});
const addError = new Error(`Client ${c.name} from ${c.source} was not added because it had unrecoverable errors`, {cause: e});
this.emitter.emit('error', addError);
this.logger.error(addError);
}
@@ -304,17 +304,17 @@ ${sources.join('\n')}`);
if (isValidConfig !== true) {
throw new Error(`Config object from ${clientConfig.source || 'unknown'} with name [${clientConfig.name || 'unnamed'}] of type [${clientConfig.type || 'unknown'}] has errors: ${isValidConfig.join(' | ')}`)
}*/
const {type, name, enable = true, data: d = {}} = clientConfig;
const {type, name, enable = true, source, data: d = {}} = clientConfig;
if(enable === false) {
this.logger.warn(`${type} (${name}) client was disabled by config`);
this.logger.warn({labels: [`${type} - ${name}`]}, `Client from ${source} was disabled by config`);
return;
}
// add defaults
const data = {...defaults, ...d};
let newClient;
this.logger.debug(`Constructing ${type} (${name}) client...`);
this.logger.debug({labels: [`${type} - ${name}`]}, `Constructing Client from ${source}`);
switch (type) {
case 'maloja':
newClient = new MalojaScrobbler(name, ({...clientConfig, data} as unknown as MalojaClientConfig), notifier, this.emitter, this.logger);
@@ -331,9 +331,9 @@ ${sources.join('\n')}`);
if(newClient === undefined) {
// really shouldn't get here!
throw new Error(`Client of type ${type} was not recognized??`);
throw new Error(`Client of type ${type} from ${source} was not recognized??`);
}
newClient.logger.info('Client Added');
newClient.logger.info(`Client Added from ${source}`);
this.clients.push(newClient);
}
+6 -5
View File
@@ -753,7 +753,7 @@ export default class ScrobbleSources {
try {
await this.addSource(c, sourceDefaults);
} catch(e) {
const addError = new Error(`Source ${c.name} of type ${c.type} was not added because of unrecoverable errors`, {cause: e});
const addError = new Error(`Source ${c.name} of type ${c.type} from source ${c.source} was not added because of unrecoverable errors`, {cause: e});
this.emitter.emit('error', addError);
this.logger.error(addError);
}
@@ -768,17 +768,17 @@ export default class ScrobbleSources {
// throw new Error(`Config object from ${clientConfig.source || 'unknown'} with name [${clientConfig.name || 'unnamed'}] of type [${clientConfig.type || 'unknown'}] has errors: ${isValidConfig.join(' | ')}`)
// }
const {type, name, data: d = {}, enable = true, options: clientOptions = {}} = clientConfig;
const {type, name, data: d = {}, enable = true, source, options: clientOptions = {}} = clientConfig;
if(enable === false) {
this.logger.warn(`${type} (${name}) source was disabled by config`);
this.logger.warn({labels: [`${type} - ${name}`]},`Source from ${source} was disabled by config`);
return;
}
// add defaults
const compositeConfig: SourceConfig = {...clientConfig, data: d, options: {...defaults, ...clientOptions}};
this.logger.debug(`(${name}) Constructing ${type} source`);
this.logger.debug({labels: [`${type} - ${name}`]},`Constructing Source from ${source}...`);
let newSource: AbstractSource;
switch (type) {
case 'spotify':
@@ -871,9 +871,10 @@ export default class ScrobbleSources {
if(newSource === undefined) {
// really shouldn't get here!
this.logger.error(new Error(`Source of type ${type} was not recognized??`));
this.logger.error(new Error(`Source of type ${type} from ${source} was not recognized??`));
return;
}
this.sources.push(newSource);
newSource.logger.info(`Source Added from ${source}`);
}
}