Skip to content

Commit

Permalink
Allow suppressing bootstrap log messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Christof Hahn authored and Christof Hahn committed Aug 11, 2021
1 parent 84c31ad commit f3968f4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
3 changes: 2 additions & 1 deletion lib/logger-factory-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ export class LoggerFactoryConfig {
/** appenders */
appenders: string[];
consoleFeature?: boolean;
consoleContext?: string
consoleContext?: string;
suppressBootstrapLogging?: boolean
}
16 changes: 11 additions & 5 deletions lib/logger-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ export class LoggerFactory {
this.theInstance.theRootLevel = config.rootLevel;
}
this.theInstance.restoreConfig();
console.log(`Logging system initialized with root level '${Level[this.theInstance.theRootLevel]}'.`);
if (! config.suppressBootstrapLogging) {
console.log(`Logging system initialized with root level '${Level[this.theInstance.theRootLevel]}'.`);
}
// make ourselves available on the console if allowed by app config
if (config.consoleFeature) {
const consoleContext = config.consoleContext ? config.consoleContext : 'lf';
Expand All @@ -89,11 +91,15 @@ export class LoggerFactory {
Object.keys(Level)
.filter(level => isNaN(+level))
.forEach(level => context[level] = level);
console.log(`Logging cli is available at '${consoleContext}'.`);
if (! config.suppressBootstrapLogging) {
console.log(`Logging cli is available at '${consoleContext}'.`);
}
} else {
console.log(
'No window object available, reduced functionality.'
);
if (! config.suppressBootstrapLogging) {
console.log(
'No window object available, reduced functionality.'
);
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "yalog4ts",
"version": "1.0.3",
"version": "1.0.4",
"description": "A log4j-like logger for ts",
"main": "dist/lib/index.js",
"types": "dist/lib/index.d.ts",
Expand Down

0 comments on commit f3968f4

Please sign in to comment.