import { __esmMin } from "../../../_virtual/_rolldown/runtime.js";
//#region src/utils/logger/stats.ts
/**
* Increment statistics for a log entry
*/
function incrementStats(level, module) {
	stats.byLevel[level]++;
	if (module) {
		const current = stats.byModule.get(module) || 0;
		stats.byModule.set(module, current + 1);
	}
	if (level === "error" || level === "fatal") {
		const now = Date.now();
		if (now - stats.lastErrorTime > 1440 * 60 * 1e3) stats.errorsLast24h = 0;
		stats.errorsLast24h++;
		stats.lastErrorTime = now;
	}
}
/**
* Get current statistics
*/
function getLogStats() {
	return {
		byLevel: { ...stats.byLevel },
		byModule: Object.fromEntries(stats.byModule),
		errorsLast24h: stats.errorsLast24h,
		uptimeMs: Date.now() - stats.startTime
	};
}
/**
* Reset statistics (for testing)
*/
function resetStats() {
	stats.byLevel = {
		trace: 0,
		debug: 0,
		info: 0,
		warn: 0,
		error: 0,
		fatal: 0,
		silent: 0
	};
	stats.byModule.clear();
	stats.errorsLast24h = 0;
	stats.lastErrorTime = 0;
	stats.startTime = Date.now();
}
var stats;
var init_stats = __esmMin((() => {
	stats = {
		byLevel: {
			trace: 0,
			debug: 0,
			info: 0,
			warn: 0,
			error: 0,
			fatal: 0,
			silent: 0
		},
		byModule: /* @__PURE__ */ new Map(),
		errorsLast24h: 0,
		lastErrorTime: 0,
		startTime: Date.now()
	};
}));
//#endregion
init_stats();
export { getLogStats, incrementStats, init_stats, resetStats };

//# sourceMappingURL=stats.js.map