diff --git a/src/sheets/actor/SkillsList.svelte b/src/sheets/actor/SkillsList.svelte
index 70ec83170..fdba27beb 100644
--- a/src/sheets/actor/SkillsList.svelte
+++ b/src/sheets/actor/SkillsList.svelte
@@ -7,6 +7,7 @@
import type { CharacterSheetContext, NpcSheetContext } from 'src/types/types';
import { ActiveEffectsHelper } from 'src/utils/active-effect';
import { formatAsModifier } from 'src/utils/formatting';
+ import { warn } from 'src/utils/logging';
import { getContext } from 'svelte';
import type { Readable } from 'svelte/store';
@@ -29,17 +30,31 @@
};
let skillRefs: SkillRef[];
- $: skillRefs = Array.from(Object.entries($context.config.skills)).map(
- ([key, { label }]: [string, any]) => {
+ $: {
+ skillRefs = Array.from(Object.entries($context.config.skills)).reduce<
+ SkillRef[]
+ >((prev, [key, configSkill]: [string, any]) => {
const skill = getSkill(key);
- return {
+
+ if (!skill) {
+ warn(
+ 'Unable to find skill. Ensure custom skills are added at "init" time.',
+ false,
+ { key, configSkill },
+ );
+ return prev;
+ }
+
+ prev.push({
key: key,
- label: label,
+ label: configSkill.label,
ability: skill.ability,
skill: skill,
- };
- },
- );
+ });
+
+ return prev;
+ }, []);
+ }
$: abilities = FoundryAdapter.getAbilitiesAsDropdownOptions(
$context.abilities,
diff --git a/src/utils/logging.ts b/src/utils/logging.ts
index c32419175..74ceb0b68 100644
--- a/src/utils/logging.ts
+++ b/src/utils/logging.ts
@@ -1,7 +1,6 @@
// ================================
// Logger utility
// ================================
-// export let debugEnabled = 0;
import { CONSTANTS } from 'src/constants';
import { SettingsProvider } from 'src/settings/settings';
@@ -10,6 +9,7 @@ import { SettingsProvider } from 'src/settings/settings';
export function debug(msg: string, args?: any) {
if (SettingsProvider.settings.debug.get()) {
let formattedMsg = `DEBUG | ${CONSTANTS.MODULE_ID} | ${msg}`;
+
if (args !== undefined) {
console.log(formattedMsg, args);
} else {
@@ -17,27 +17,67 @@ export function debug(msg: string, args?: any) {
}
}
}
+
export function log(message: string, args?: any) {
message = `${CONSTANTS.MODULE_ID} | ${message}`;
- console.log(message.replace('
', '\n'), args);
+
+ const formattedLog = message.replace('
', '\n');
+
+ if (args !== undefined) {
+ console.log(formattedLog, args);
+ } else {
+ console.log(formattedLog);
+ }
}
+
export function notify(message: string) {
message = `${CONSTANTS.MODULE_ID} | ${message}`;
ui.notifications?.notify(message);
console.log(message.replace('
', '\n'));
}
-export function info(info: string, notify = false) {
+
+export function info(info: string, notify = false, args?: any) {
info = `${CONSTANTS.MODULE_ID} | ${info}`;
- if (notify) ui.notifications?.info(info);
- console.log(info.replace('
', '\n'));
+
+ if (notify) {
+ ui.notifications?.info(info);
+ }
+
+ const formattedInfo = info.replace('
', '\n');
+
+ if (args !== undefined) {
+ console.log(formattedInfo, args);
+ } else {
+ console.log(formattedInfo);
+ }
}
-export function warn(warning: string, notify = false) {
+
+export function warn(warning: string, notify = false, args?: any) {
warning = `${CONSTANTS.MODULE_ID} | ${warning}`;
- if (notify) ui.notifications?.warn(warning);
- console.warn(warning.replace('
', '\n'));
+
+ if (notify) {
+ ui.notifications?.warn(warning);
+ }
+
+ const formattedWarning = warning.replace('
', '\n');
+
+ if (args !== undefined) {
+ console.warn(formattedWarning, args);
+ } else {
+ console.warn(formattedWarning);
+ }
}
+
export function error(message: string, notify = true, args?: any) {
message = `${CONSTANTS.MODULE_ID} | ${message}`;
- if (notify) ui.notifications?.error(message);
- console.error(message, args);
+
+ if (notify) {
+ ui.notifications?.error(message);
+ }
+
+ if (args !== undefined) {
+ console.error(message, args);
+ } else {
+ console.error(message);
+ }
}