// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
import { NoTarget } from "@typespec/compiler";
import { getTracer, reportDiagnostic as libReportDiagnostic, } from "./lib.js";
import { LoggerLevel } from "./logger-level.js";
/**
 * The Logger class for the emitter.
 * @beta
 */
export class Logger {
    tracer;
    level;
    program;
    constructor(program, level) {
        this.tracer = getTracer(program);
        this.level = level;
        this.program = program;
    }
    trace(level, message) {
        switch (level) {
            case LoggerLevel.INFO:
                this.info(message);
                break;
            case LoggerLevel.DEBUG:
                this.debug(message);
                break;
            case LoggerLevel.VERBOSE:
                this.verbose(message);
                break;
        }
    }
    info(message) {
        if (this.level === LoggerLevel.INFO ||
            this.level === LoggerLevel.DEBUG ||
            this.level === LoggerLevel.VERBOSE) {
            this.tracer.trace(LoggerLevel.INFO, message);
        }
    }
    debug(message) {
        if (this.level === LoggerLevel.DEBUG || this.level === LoggerLevel.VERBOSE) {
            this.tracer.trace(LoggerLevel.DEBUG, message);
        }
    }
    verbose(message) {
        if (this.level === LoggerLevel.VERBOSE) {
            this.tracer.trace(LoggerLevel.VERBOSE, message);
        }
    }
    reportDiagnostic(diag) {
        libReportDiagnostic(this.program, diag);
    }
    warn(message) {
        this.reportDiagnostic({
            code: "general-warning",
            format: { message: message },
            target: NoTarget,
        });
    }
    error(message) {
        this.reportDiagnostic({
            code: "general-error",
            format: { message: message },
            target: NoTarget,
        });
    }
}
//# sourceMappingURL=logger.js.map