Skip to content

Commit

Permalink
Check if verbose level is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
LucaScorpion committed Aug 15, 2024
1 parent 00b9d9e commit b9ec21d
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/AutoloadModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export function AutoloadModule(
metadata?: ModuleMetadata
): ClassDecorator {
return (target) => {
logger.verbose(`Autoloading module: ${dirName}`);
log(`Autoloading module: ${dirName}`);
const loaded = loadScripts(dirName);
const combinedMeta: ModuleMetadata = {
...metadata,
Expand All @@ -39,7 +39,7 @@ function loadScripts(dirName: string): LoadResult {
};

for (const script of scripts) {
logger.verbose(`Autoloading file: ${script}`);
log(`Autoloading file: ${script}`);

// Here we have to use require, to get the exports into a variable.
// eslint-disable-next-line @typescript-eslint/no-var-requires
Expand All @@ -48,12 +48,12 @@ function loadScripts(dirName: string): LoadResult {
for (const check of reqVals) {
if (typeof check === 'function') {
if (isController(check)) {
logger.verbose(`Found controller: ${check.name}`);
log(`Found controller: ${check.name}`);
result.controllers.push(check);
}

if (isProvider(check)) {
logger.verbose(`Found provider: ${check.name}`);
log(`Found provider: ${check.name}`);
result.providers.push(check);
}
}
Expand All @@ -63,6 +63,12 @@ function loadScripts(dirName: string): LoadResult {
return result;
}

function log(message: string): void {
if (Logger.isLevelEnabled('verbose')) {
logger.verbose(message);
}
}

// For both of these functions,
// we specifically want to use the Object type because it accepts almost anything.

Expand Down

0 comments on commit b9ec21d

Please sign in to comment.