mirror of
https://github.com/FoxxMD/context-mod.git
synced 2026-04-19 03:00:07 -04:00
Update some logging to be more subreddit specific
This commit is contained in:
16
src/App.ts
16
src/App.ts
@@ -178,7 +178,7 @@ export class App {
|
||||
let subsToRun: Subreddit[] = [];
|
||||
const subsToUse = subreddits.length > 0 ? subreddits.map(parseSubredditName) : this.subreddits;
|
||||
if (subsToUse.length > 0) {
|
||||
this.logger.info(`User-defined subreddit constraints detected (CLI argument or environmental variable), will try to run on: ${subsToUse.join(', ')}`);
|
||||
this.logger.info(`Operator-defined subreddit constraints detected (CLI argument or environmental variable), will try to run on: ${subsToUse.join(', ')}`);
|
||||
for (const sub of subsToUse) {
|
||||
const asub = availSubs.find(x => x.display_name.toLowerCase() === sub.toLowerCase())
|
||||
if (asub === undefined) {
|
||||
@@ -205,19 +205,19 @@ export class App {
|
||||
wiki = await sub.getWikiPage(this.wikiLocation).fetch();
|
||||
content = wiki.content_md;
|
||||
} catch (err) {
|
||||
this.logger.error(`{${sub.display_name_prefixed}} Could not read wiki configuration. Please ensure the page https://reddit.com${sub.url}wiki/${this.wikiLocation} exists and is readable -- error: ${err.message}`);
|
||||
this.logger.error(`Could not read wiki configuration. Please ensure the page https://reddit.com${sub.url}wiki/${this.wikiLocation} exists and is readable -- error: ${err.message}`, {subreddit: sub.display_name_prefixed});
|
||||
continue;
|
||||
}
|
||||
|
||||
if (content === '') {
|
||||
this.logger.error(`{${sub.display_name_prefixed}} Wiki page contents was empty`);
|
||||
this.logger.error('Wiki page contents was empty`', {subreddit: sub.display_name_prefixed});
|
||||
continue;
|
||||
}
|
||||
|
||||
const [configObj, jsonErr, yamlErr] = parseFromJsonOrYamlToObject(content);
|
||||
|
||||
if (configObj === undefined) {
|
||||
this.logger.error(`{${sub.display_name_prefixed}} Could not parse wiki page contents as JSON or YAML:`);
|
||||
this.logger.error(`Could not parse wiki page contents as JSON or YAML:`, {subreddit: sub.display_name_prefixed});
|
||||
this.logger.error(jsonErr);
|
||||
this.logger.error(yamlErr);
|
||||
continue;
|
||||
@@ -230,7 +230,8 @@ export class App {
|
||||
subSchedule.push(manager);
|
||||
} catch (err) {
|
||||
if (!(err instanceof LoggedError)) {
|
||||
this.logger.error(`{${sub.display_name_prefixed}} Config was not valid`, err);
|
||||
this.logger.error(`Config was not valid:`, {subreddit: sub.display_name_prefixed});
|
||||
this.logger.error(err, {subreddit: sub.display_name_prefixed});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -259,7 +260,10 @@ export class App {
|
||||
} catch (err) {
|
||||
s.stop();
|
||||
if(!(err instanceof LoggedError)) {
|
||||
this.logger.info('Will retry parsing config on next heartbeat...');
|
||||
this.logger.error(err, {subreddit: s.displayLabel});
|
||||
}
|
||||
if(this.nextHeartbeat !== undefined) {
|
||||
this.logger.info(`Will retry parsing config on next heartbeat (in ${dayjs.duration(this.nextHeartbeat.diff(dayjs())).humanize()})`, {subreddit: s.displayLabel});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -226,14 +226,12 @@ export class Manager {
|
||||
} catch (err) {
|
||||
const msg = `Could not read wiki configuration. Please ensure the page https://reddit.com${this.subreddit.url}wiki/${this.wikiLocation} exists and is readable -- error: ${err.message}`;
|
||||
this.logger.error(msg);
|
||||
this.logger.info('Will retry parsing config on next heartbeat...');
|
||||
this.wikiUpdateRunning = false;
|
||||
throw new ConfigParseError(msg);
|
||||
}
|
||||
|
||||
if (sourceData === '') {
|
||||
this.logger.error(`Wiki page contents was empty`);
|
||||
this.logger.info('Will retry parsing config on next heartbeat...');
|
||||
this.wikiUpdateRunning = false;
|
||||
throw new ConfigParseError('Wiki page contents was empty');
|
||||
}
|
||||
@@ -244,9 +242,8 @@ export class Manager {
|
||||
this.logger.error(`Could not parse wiki page contents as JSON or YAML:`);
|
||||
this.logger.error(jsonErr);
|
||||
this.logger.error(yamlErr);
|
||||
this.logger.info('Will retry parsing config on next heartbeat...');
|
||||
this.wikiUpdateRunning = false;
|
||||
throw new ConfigParseError('Could not parse wiki page contents as JSON or YAML:')
|
||||
throw new ConfigParseError('Could not parse wiki page contents as JSON or YAML')
|
||||
}
|
||||
|
||||
this.wikiUpdateRunning = false;
|
||||
@@ -263,7 +260,7 @@ export class Manager {
|
||||
const itemId = await item.id;
|
||||
let allRuleResults: RuleResult[] = [];
|
||||
const itemIdentifier = `${checkType === 'Submission' ? 'SUB' : 'COM'} ${itemId}`;
|
||||
this.currentLabels = [this.displayLabel, itemIdentifier];
|
||||
this.currentLabels = [itemIdentifier];
|
||||
const [peek, _] = await itemContentPeek(item);
|
||||
this.logger.info(`<EVENT> ${peek}`);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user