All files logger.mjs

91.3% Statements 21/23
75% Branches 3/4
100% Functions 2/2
91.3% Lines 21/23

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 231x 2x 2x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 2x 2x 7x     7x 2x 2x 2x
 
class Logger {
    constructor(moduleName) {
        this.enabled = true;
        this.level = 'info';
        this.moduleName = moduleName;
 
        if(navigator.userAgent.includes('jsdom')) {
            this.enabled = false;
        }
 
        this.log(`Logger initialized for module: ${this.moduleName}`);
        this.log(`Browser Info: ${navigator.userAgent}`);
    }
    
    log(message) {
        if(this.enabled) {
            console.log(`${this.moduleName}:`, message);
        }
    }
}
 
export default Logger;