# Class PlatformLogMiddleware

Class middleware platform
Module
import { PlatformLogMiddleware } from "@tsed/common"
Source/packages/common/src/platform/middlewares/PlatformLogMiddleware.ts

# Overview

class PlatformLogMiddleware implements IMiddleware, OnResponse {
    protected static DEFAULT_FIELDS: string[];
    $onResponse: any;
    protected settings: PlatformLoggerSettings;
    constructor(injector: InjectorService);
<span class="token function">use</span><span class="token punctuation">(</span>ctx<span class="token punctuation">:</span> <a href="/api/common/platform/decorators/Context.html"><span class="token">Context</span></a><span class="token punctuation">)</span><span class="token punctuation">:</span> <span class="token keyword">void</span><span class="token punctuation">;</span>

<span class="token keyword">protected</span> <span class="token function">onLogStart</span><span class="token punctuation">(</span>ctx<span class="token punctuation">:</span> <a href="/api/common/platform/decorators/Context.html"><span class="token">Context</span></a><span class="token punctuation">)</span><span class="token punctuation">:</span> <span class="token keyword">void</span><span class="token punctuation">;</span>

<span class="token keyword">protected</span> <span class="token function">onLogEnd</span><span class="token punctuation">(</span>ctx<span class="token punctuation">:</span> <a href="/api/common/platform/decorators/Context.html"><span class="token">Context</span></a><span class="token punctuation">)</span><span class="token punctuation">:</span> <span class="token keyword">void</span><span class="token punctuation">;</span>

<span class="token keyword">protected</span> <span class="token function">configureRequest</span><span class="token punctuation">(</span>ctx<span class="token punctuation">:</span> <a href="/api/common/platform/decorators/Context.html"><span class="token">Context</span></a><span class="token punctuation">)</span><span class="token punctuation">:</span> <span class="token keyword">void</span><span class="token punctuation">;</span>

<span class="token keyword">protected</span> <span class="token function">requestToObject</span><span class="token punctuation">(</span>ctx<span class="token punctuation">:</span> <a href="/api/common/platform/decorators/Context.html"><span class="token">Context</span></a><span class="token punctuation">)</span><span class="token punctuation">:</span> <span class="token keyword">any</span><span class="token punctuation">;</span>

<span class="token keyword">protected</span> <span class="token function">minimalRequestPicker</span><span class="token punctuation">(</span>ctx<span class="token punctuation">:</span> <a href="/api/common/platform/decorators/Context.html"><span class="token">Context</span></a><span class="token punctuation">)</span><span class="token punctuation">:</span> <span class="token keyword">any</span><span class="token punctuation">;</span>

}

# Members

protected static DEFAULT_FIELDS: string[];

$onResponse: any;

protected settings: PlatformLoggerSettings;

use(ctx: Context): void;

Handle the request.


protected onLogStart(ctx: Context): void;

The separate onLogStart() function will allow developer to overwrite the initial request log.


protected onLogEnd(ctx: Context): void;

Called when the $onResponse is called by Ts.ED (through Express.end).


protected configureRequest(ctx: Context): void;

Attach all information that will be necessary to log the request. Attach a new request.log object.


protected requestToObject(ctx: Context): any;

Return complete request info.


protected minimalRequestPicker(ctx: Context): any;

Return a filtered request from global configuration.

Other topics