mirror of
https://github.com/danieleteti/delphimvcframework.git
synced 2024-11-17 16:55:54 +01:00
55500acdf9
git-subtree-dir: lib/loggerpro git-subtree-split: d1e0db6e93724e5fd825f0a8c02151d60450f98f
57 lines
1.3 KiB
ObjectPascal
57 lines
1.3 KiB
ObjectPascal
unit LogsCollectorControllerU;
|
|
|
|
interface
|
|
|
|
uses
|
|
MVCFramework,
|
|
MVCFramework.Commons;
|
|
|
|
type
|
|
|
|
[MVCPath('/api')]
|
|
TLogsCollectorController = class(TMVCController)
|
|
public
|
|
[MVCPath('/logs/($logtag)/($logtype)')]
|
|
[MVCHTTPMethod([httpPOST])]
|
|
[MVCConsumes(TMVCMediaType.TEXT_PLAIN)]
|
|
procedure Logs(const logtag, logtype: string);
|
|
|
|
protected
|
|
procedure OnBeforeAction(Context: TWebContext; const AActionName: string; var Handled: Boolean); override;
|
|
procedure OnAfterAction(Context: TWebContext; const AActionName: string); override;
|
|
|
|
public
|
|
end;
|
|
|
|
implementation
|
|
|
|
uses
|
|
System.SysUtils,
|
|
System.StrUtils,
|
|
LoggerProConfig,
|
|
LoggerPro;
|
|
|
|
procedure TLogsCollectorController.Logs(const logtag, logtype: string);
|
|
var
|
|
lLogType: TLogType;
|
|
begin
|
|
lLogType := LoggerPro.StringToLogType(logtype);
|
|
Log.Log(lLogType, Context.Request.Body, logtag);
|
|
end;
|
|
|
|
procedure TLogsCollectorController.OnAfterAction(Context: TWebContext; const AActionName: string);
|
|
begin
|
|
{ Executed after each action }
|
|
inherited;
|
|
end;
|
|
|
|
procedure TLogsCollectorController.OnBeforeAction(Context: TWebContext; const AActionName: string; var Handled: Boolean);
|
|
begin
|
|
{ Executed before each action
|
|
if handled is true (or an exception is raised) the actual
|
|
action will not be called }
|
|
inherited;
|
|
end;
|
|
|
|
end.
|