import { formatOutput, formatSuccess } from '../output.js';
import { ClientError } from '../../lib/errors.js';
import { withMcpClient } from '../helpers.js';
const VALID_LOG_LEVELS = ['debug', 'info', 'notice', 'warning', 'error', 'critical', 'alert', 'emergency'];
export async function setLogLevel(target, level, options) {
    if (!VALID_LOG_LEVELS.includes(level)) {
        throw new ClientError(`Invalid log level: ${level}. Must be one of: ${VALID_LOG_LEVELS.join(', ')}`);
    }
    await withMcpClient(target, options, async (client, _context) => {
        await client.setLoggingLevel(level);
        if (options.outputMode === 'human') {
            console.log(formatSuccess(`Server log level set to: ${level}`));
        }
        else {
            console.log(formatOutput({
                level,
                success: true,
            }, 'json'));
        }
    });
}
//# sourceMappingURL=logging.js.map