import * as uuid from "uuid";
import pino from "pino";
export class StructuredLogger {
    constructor(log = pino({
        level: process.env.LOG_LEVEL || "trace",
    })) {
        this.log = log;
    }
    started(address, telemetryEnabled) {
        this.log.info(`Listening on ${address}`);
        if (telemetryEnabled) {
            this.log.info(`
      Quirrel collects completely anonymous telemetry data about general usage,
      opt-out by setting the DISABLE_TELEMETRY environment variable.`);
        }
    }
    executionErrored(job, error) {
        this.log.error({ error, job }, "Caught error during execution");
    }
    jobCreated(job) {
        this.log.info({ job }, "Created job.");
    }
    jobDeleted(job) {
        this.log.info({ job }, "Deleted job.");
    }
    cronUpdated(crons, deleted) {
        this.log.info({ crons, deleted }, "updated crons");
    }
    startingExecution(job) {
        const child = this.log.child({ correlationId: uuid.v4() });
        child.info({ job }, "Started execution of job.");
        return () => {
            child.info({ job }, "Ended execution of job");
        };
    }
}
//# sourceMappingURL=structured-logger.js.map