{"size": 1715, "ext": "js", "max_stars_repo_path": "dist/logger.js", "max_stars_repo_name": "ThomasMoritz/nest-keycloak-connect", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "dist/logger.js", "max_issues_repo_name": "ThomasMoritz/nest-keycloak-connect", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "dist/logger.js", "max_forks_repo_name": "ThomasMoritz/nest-keycloak-connect", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 33.6274509804, "max_line_length": 102, "alphanum_fraction": 0.6256559767}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.KeycloakLogger = void 0;
const common_1 = require("@nestjs/common");
/**
 * Wrapper for Nest Logger. Will be removed in 2.0.
 */
class KeycloakLogger {
    constructor(providedLogLevels) {
        this.logger = new common_1.Logger('Keycloak');
        this.DEFAULT_LOG_LEVEL = 'log';
        this.setDefaultLogLevel = () => {
            this.logLevels = [this.DEFAULT_LOG_LEVEL];
            this.logger.verbose('No LogLevel for KeycloakLogger provided; falling back to default: ' +
                this.DEFAULT_LOG_LEVEL);
        };
        this.isLogLevelSet = (logLevels) => Array.isArray(logLevels) && logLevels.length;
        this.isLogLevelSet(providedLogLevels)
            ? (this.logLevels = providedLogLevels)
            : this.setDefaultLogLevel();
    }
    log(message, context) {
        this.callWrapped('log', message, context);
    }
    error(message, trace, context) {
        this.callWrapped('error', message, context);
    }
    warn(message, context) {
        this.callWrapped('warn', message, context);
    }
    debug(message, context) {
        this.callWrapped('debug', message, context);
    }
    verbose(message, context) {
        this.callWrapped('verbose', message, context);
    }
    isLogLevelEnabled(level) {
        return this.logLevels.includes(level);
    }
    callWrapped(name, message, 
    // eslint-disable-next-line @typescript-eslint/no-unused-vars
    context) {
        if (!this.isLogLevelEnabled(name)) {
            return;
        }
        const func = this.logger[name];
        func && func.call(this.logger, message);
    }
}
exports.KeycloakLogger = KeycloakLogger;
