const path = require('path');

function debuggers (filename) {
	const ns = filename
		? "dougal:server:"+path.basename(path.relative(__dirname, filename).replace(/\//g, ':'), path.extname(filename)).replace(/:index$/, "")
		: "dougal:server";
	const debug = require('debug')(ns);
	return {
		debug,

		// A "panic" condition affecting multiple applications, servers, or sites.
		// System is unusable. Notify all technical staff on call.
		EMERGENCY: debug.extend("EMERGENCY"),

		// A condition requiring immediate correction or indicating a failure in a
		// primary system, for example, a loss of a primary ISP connection.
		// Fix CRITICAL issues before ALERT-level problems.
		CRITICAL: debug.extend("CRITICAL"),

		// A condition requiring immediate correction, for example, the loss of a
		// backup ISP connection. Notify staff who can fix the problem.
		ALERT: debug.extend("ALERT"),

		// Non-urgent failures. Notify developers or administrators as errors must
		// be resolved within a given time.
		ERROR: debug.extend("ERROR"),

		// Warning messages are not errors, but they indicate that an error will occur
		// if required action is not taken. An example is a file system that is 85% full.
		// Each item must be resolved within a given time.
		WARNING: debug.extend("WARNING"),

		// Events that are unusual but are not error conditions. These items might be
		// summarized in an email to developers or administrators to spot potential
		// problems. No immediate action is required.
		NOTICE: debug.extend("NOTICE"),

		// Normal operational messages. These may be harvested for network maintenance
		// functions like reporting and throughput measurement. No action is required.
		INFO: debug.extend("INFO"),

		// Information useful to developers for debugging an application. This information
		// is not useful during operations.
		DEBUG: debug.extend("DEBUG"),
	};
}

module.exports = debuggers;
