/**
 * Wraps a Homebridge Logging instance to apply a user-selected verbosity
 * filter. Returns the original logger unchanged when level is 'normal'
 * (zero overhead). For 'quiet' and 'errors-only', returns a callable
 * function wrapper that no-ops the suppressed methods and delegates the
 * rest to the original logger.
 *
 * Wrapping at the platform level cascades to every device class that reads
 * `this.platform.log` (PicoRemote, OccupancySensor, SerenaTiltOnlyWoodBlinds,
 * ButtonTracker via PicoRemote), so this single wrap point governs the
 * whole plugin.
 */
export function createFilteredLogger(base, level) {
    // 'normal' or any unexpected value → passthrough. Defensive: if a hand-edited
    // config.json supplies a string we don't recognise, never silently suppress.
    if (level !== 'quiet' && level !== 'errors-only') {
        return base;
    }
    const suppressInfo = true; // both 'quiet' and 'errors-only' suppress info+success
    const suppressWarn = level === 'errors-only';
    const noop = () => { };
    // Logging is callable AND has methods; build a function with attached
    // properties to satisfy both shapes. The callable form behaves like info().
    const fn = function wrappedLogger(msg, ...params) {
        if (suppressInfo) {
            return;
        }
        base(msg, ...params);
    };
    fn.prefix = base.prefix;
    fn.info = suppressInfo ? noop : base.info.bind(base);
    fn.success = suppressInfo ? noop : base.success.bind(base);
    fn.warn = suppressWarn ? noop : base.warn.bind(base);
    fn.error = base.error.bind(base);
    fn.debug = base.debug.bind(base);
    fn.log = (lvl, msg, ...params) => {
        // LogLevel is a const enum whose values are the strings 'info'/'success'/
        // 'warn'/'error'/'debug', so equality checks against string literals are
        // type-correct and stable across const-enum erasure.
        if (suppressInfo && (lvl === 'info' || lvl === 'success')) {
            return;
        }
        if (suppressWarn && lvl === 'warn') {
            return;
        }
        base.log(lvl, msg, ...params);
    };
    return fn;
}
/**
 * Emit a button-press log line at the level specified by the user's
 * 'buttonPressLogging' option. Used by both PicoRemote (for raw
 * Press/Release events received from the bridge) and ButtonTracker (for
 * interpreted short/long/double press events derived from the state
 * machine). Centralised here so the three states stay in sync between
 * the two call sites.
 */
export function logButtonPress(log, level, message, ...params) {
    switch (level) {
        case 'info':
            log.info(message, ...params);
            break;
        case 'debug':
            log.debug(message, ...params);
            break;
        case 'silent':
            // intentionally drop
            break;
    }
}
//# sourceMappingURL=Logger.js.map