[AWS] [Patch] Added support for external log handlers

Thomas Løcke thomas.granvej6 at gmail.com
Tue Nov 8 18:22:32 CET 2011


Hey all,

Attached is my proposed patch for adding external log handlers to AWS. The
goal of the patch is to enable users to direct AWS log data to something
like syslog.

With the patch, it's pretty simple to hand over the AWS log data to an
external procedure:

with Ada.Text_IO;
package body Logging is
   procedure Access_Log
     (Message : in String)
   is
   begin
      Ada.Text_IO.Put_Line ("Access: " & Message);
   end Access_Log;

   procedure Error_Log
     (Message : in String)
   is
   begin
      Ada.Text_IO.Put_Line ("Error: " & Message);
   end Error_Log;
end Logging;

with ....
with Logging;
procedure Foo is
   WS : AWS.Server.HTTP;
begin
   AWS.Server.Start....;
   AWS.Server.Log.Start (Web_Server      => WS,
                                    External_Writer  =>
Logging.Access_Log'Access,
                                    Name               => "Some Access
Label");

   AWS.Server.Log.Start_Error (Web_Server      => WS,
                                             External_Writer  =>
Logging.Error_Log'Access,
                                             Name               => "Some
Error Label");

   AWS.Server.Wait (Mode => AWS.Server.Q_Key_Pressed);
   AWS.Server.Shutdown (WS);
end Foo;

And that's basically it: New Start and Start_Error procedures, where you
can set access to a procedure that takes the log message as its sole
parameter. Obviously you can do the same with any AWS.Log object, not just
those used by AWS.Server.HTTP.

I could've added syslog support directly to AWS, but I decided against it
for three reasons:

1.) It's already available in GNATColl, using the Traces.Syslog package. No
need to duplicate the effort.

2.) Syslog isn't available on all platforms (Windows specifically).

3.) If a user have bindings to something like syslog-ng or rsyslog, they
can use those with little to no effort.

If the patch, or the method I've chosen, isn't acceptable, please consider
adding something else to AWS to accomodate this. There are many good
reasons for having log data on a separate server, chief among those being
security and performance.

Sincerely,
Thomas Løcke
-------------- next part --------------
An HTML attachment was scrubbed...
URL: /pipermail/aws/attachments/20111108/dd8a5319/attachment.htm 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Added-support-for-external-log-handlers.patch
Type: text/x-patch
Size: 18331 bytes
Desc: not available
Url : /pipermail/aws/attachments/20111108/dd8a5319/attachment-0001.bin 


More information about the AWS mailing list