mirror of
https://github.com/0rangebananaspy/authelia.git
synced 2024-09-14 22:47:21 +07:00
73d5253297
Notifier is not mandatory when authentication method is single_factor for all sub-domains since there is no registration required.
38 lines
1.2 KiB
TypeScript
38 lines
1.2 KiB
TypeScript
import { IRequestLogger } from "../../src/lib/logging/IRequestLogger";
|
|
import Sinon = require("sinon");
|
|
import { RequestLogger } from "../../src/lib/logging/RequestLogger";
|
|
import Winston = require("winston");
|
|
import Express = require("express");
|
|
|
|
export class RequestLoggerStub implements IRequestLogger {
|
|
infoStub: Sinon.SinonStub;
|
|
debugStub: Sinon.SinonStub;
|
|
errorStub: Sinon.SinonStub;
|
|
private requestLogger: RequestLogger;
|
|
|
|
constructor(enableLogging?: boolean) {
|
|
this.infoStub = Sinon.stub();
|
|
this.debugStub = Sinon.stub();
|
|
this.errorStub = Sinon.stub();
|
|
if (enableLogging)
|
|
this.requestLogger = new RequestLogger(Winston);
|
|
}
|
|
|
|
info(req: Express.Request, message: string, ...args: any[]): void {
|
|
if (this.requestLogger)
|
|
this.requestLogger.info(req, message, ...args);
|
|
this.infoStub(req, message, ...args);
|
|
}
|
|
|
|
debug(req: Express.Request, message: string, ...args: any[]): void {
|
|
if (this.requestLogger)
|
|
this.requestLogger.info(req, message, ...args);
|
|
this.debugStub(req, message, ...args);
|
|
}
|
|
|
|
error(req: Express.Request, message: string, ...args: any[]): void {
|
|
if (this.requestLogger)
|
|
this.requestLogger.info(req, message, ...args);
|
|
this.errorStub(req, message, ...args);
|
|
}
|
|
} |