1
0
Files
applications
bindings
components
examples
image_sources
lclbindings
wst
tags
trunk
doc
ide
samples
tests
SDMTabularService
amazon
apache_module
calculator
client
gui_client
srv
calculator.wst
calculator_binder.pas
calculator_imp.pas
logger_extension.pas
calculator.pas
calculator.wst_meta
delphi
ebay
files
google_api
http_server
library
metadata_browser
record
tcp_server
test_float_to_str
test_suite
type_lib_edtr
ws_helper
wst_rtti_filter
COPYING.LGPL
COPYING.modifiedLGPL
base_binary_formatter.pas
base_json_formatter.pas
base_service_intf.pas
base_soap_formatter.pas
base_xmlrpc_formatter.pas
basex_encode.pas
binary_formatter.pas
binary_streamer.pas
client_filters.pas
client_utils.pas
config_objects.pas
date_utils.pas
delphi_init_com.pas
file_logger_extension.pas
filter_intf.pas
fpc_http_protocol.pas
fpc_http_server.pas
fpc_tcp_protocol.pas
fpc_tcp_server.pas
ics_http_protocol.pas
ics_tcp_protocol.pas
imp_utils.pas
indy_http_protocol.pas
indy_http_server.pas
indy_https_server.pas
indy_tcp_protocol.pas
indy_tcp_server.pas
json_formatter.pas
library_base_intf.pas
library_imp_utils.pas
library_protocol.pas
library_server_intf.pas
logger_extension.pas
metadata_repository.pas
metadata_service.pas
metadata_service.wsdl
metadata_service.wst
metadata_service.wst_meta
metadata_service_binder.pas
metadata_service_imp.pas
metadata_service_proxy.pas
metadata_wsdl.pas
ns_http_protocol.pas
object_serializer.pas
record_rtti.pas
same_process_protocol.pas
semaphore.pas
server_binary_formatter.pas
server_filter_extension.pas
server_listener.pas
server_service_imputils.pas
server_service_intf.pas
server_service_json.pas
server_service_soap.pas
server_service_xmlrpc.pas
service_intf.pas
soap_formatter.pas
synapse_http_protocol.pas
synapse_tcp_protocol.pas
synapse_tcp_server.pas
wst.inc
wst_consts.pas
wst_delphi.inc
wst_delphi_rtl.pas
wst_delphi_rtti_utils.pas
wst_delphi_xml.pas
wst_fpc_xml.pas
wst_global.inc
wst_indy10_utils.pas
wst_indy9_utils.pas
wst_initialization.pas
wst_resources_imp.pas
wst_rtl_imp.inc
wst_types.pas
xml_serializer.pas
xmlrpc_formatter.pas
lazarus-ccr/wst/trunk/tests/calculator/srv/logger_extension.pas

82 lines
2.3 KiB
ObjectPascal
Raw Normal View History

{
This file is part of the Web Service Toolkit
Copyright (c) 2006 by Inoussa OUEDRAOGO
This file is provide under modified LGPL licence
( the files COPYING.modifiedLGPL and COPYING.LGPL).
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
}
unit logger_extension;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, base_service_intf, server_service_intf;
type
{ TLoggerServiceExtension }
TLoggerServiceExtension = class(TSimpleFactoryItem,IServiceExtension)
private
procedure TraceMessage(const AMsg : string);
protected
procedure ProcessMessage(
const AMessageStage : TMessageStage;
ACallContext : ICallContext;
AMsgData : IInterface
{ The "AMsgData" parameter actual type depends on the message state
on correspond to :
- IRequestBuffer on "msBeforeDeserialize" and "msAfterSerialize"
- IFormatterResponse on "msAfterDeserialize", "msBeforeSerialize"
}
);
end;
implementation
uses TypInfo;
{ TLoggerServiceExtension }
procedure TLoggerServiceExtension.TraceMessage(const AMsg: string);
begin
WriteLn(AMsg);
end;
procedure TLoggerServiceExtension.ProcessMessage(
const AMessageStage: TMessageStage;
ACallContext: ICallContext;
AMsgData: IInterface
);
var
s : string;
rqb : IRequestBuffer;
frmtr : IFormatterResponse;
begin
s := GetEnumName(TypeInfo(TMessageStage),Ord(AMessageStage));
case AMessageStage of
msBeforeDeserialize, msAfterSerialize :
begin
rqb := AMsgData as IRequestBuffer;
s := Format('Called service : "%s"; Processing stage : "%s"',[rqb.GetTargetService(),s]);
end;
msAfterDeserialize, msBeforeSerialize :
begin
frmtr := AMsgData as IFormatterResponse;
s := Format('Called service : "%s"; Target Operation = "%s"; Processing stage : "%s"',[frmtr.GetCallTarget(),frmtr.GetCallProcedureName(),s]);
end;
end;
TraceMessage(s);
end;
initialization
GetServiceExtensionRegistry().Register('TLoggerServiceExtension',TSimpleItemFactory.Create(TLoggerServiceExtension) as IItemFactory);
end.