--------------------------------------------------------------------------------
--                                                                            --
-- Copyright (C) 2004, RISC OS Ada Library (RASCAL) developers.               --
--                                                                            --
-- This library is free software; you can redistribute it and/or              --
-- modify it under the terms of the GNU Lesser General Public                 --
-- License as published by the Free Software Foundation; either               --
-- version 2.1 of the License, or (at your option) any later version.         --
--                                                                            --
-- This library 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. See the GNU           --
-- Lesser General Public License for more details.                            --
--                                                                            --
-- You should have received a copy of the GNU Lesser General Public           --
-- License along with this library; if not, write to the Free Software        --
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA    --
--                                                                            --
--------------------------------------------------------------------------------

-- @brief Binding to Syslog.
-- $Author$
-- $Date$
-- $Revision$

with System; use System;

package RASCAL.Syslog is

   SysLog_LogMessage       : constant := 16#04C880#;
   SysLog_GetLogLevel      : constant := 16#04C881#;
   SysLog_FlushLog         : constant := 16#04C882#;
   SysLog_SetLogLevel      : constant := 16#04C883#;
   SysLog_LogUnstamped     : constant := 16#04C884#;
   SysLog_Indent           : constant := 16#04C885#;
   SysLog_UnIndent         : constant := 16#04C886#;
   SysLog_NoIndent         : constant := 16#04C887#;
   SysLog_OpenSessionLog   : constant := 16#04C888#;
   SysLog_CloseSessionLog  : constant := 16#04C889#;
   SysLog_LogData          : constant := 16#04C88A#;
--   SysLog_LogFormatted     : constant := 16#04C88B#;
   SysLog_ReadErrorMessage : constant := 16#04C88C#;
   SysLog_LogComplete      : constant := 16#04C88D#;
--   SysLog_IRQMode          : constant := 16#04C88E#;
--   SysLog_LogCharacter     : constant := 16#04C88F#;
--   SysLog_Control          : constant := 16#04C890#;
--   SysLog_Enumerate        : constant := 16#04C891#;

   type Syslog_Handle_Type is new Integer;
   type Syslog_Level_Type  is new Integer range 0..255;

   Critical       : constant Syslog_Level_Type := 0;
   Serious        : constant Syslog_Level_Type := 50;
   Worth_Noticing : constant Syslog_Level_Type := 124;
   UnImportant    : constant Syslog_Level_Type := 255;

   --
   -- Log a message in a named system log or session log.
   --
   procedure Log_Message (Name    : in String;
                          Message : in String;
                          Level   : in Syslog_Level_Type);

   --
   -- Log a message in a system log or session log.
   --
   procedure Log_Message (Handle  : in Syslog_Handle_Type;
                          Message : in String;
                          Level   : in Syslog_Level_Type);

   --
   -- Read the current logging level for a particular log.
   --
   function Get_LogLevel (Name : in String) return Integer;

   --
   -- Read the current logging level for a particular log.
   --
   function Get_LogLevel (Handle : in Syslog_Handle_Type) return Integer;

   --
   -- Writes any cached data from memory to the logs and closes the files.
   --
   procedure Flush_Log (Name : in String);

   --
   -- Writes any cached data from memory to the logs and closes the files.
   --
   procedure Flush_Log (Handle : in Syslog_Handle_Type);

   --
   -- Set the current logging level for a particular log.
   --
   procedure Set_LogLevel (Name  : in String;
                           Level : in Syslog_Level_Type);

   --
   -- Set the current logging level for a particular log.
   --
   procedure Set_LogLevel (Handle : in Syslog_Handle_Type;
                           Level  : in Syslog_Level_Type);

   --
   -- Log a message in a named system log or session log without stamping it with the time and date.
   --
   procedure Log_UnStamped (Name    : in String;
                            Message : in String;
                            Level   : in Syslog_Level_Type);

   --
   -- Log a message in a system log or session log without stamping it with the time and date.
   --
   procedure Log_UnStamped (Handle  : in Syslog_Handle_Type;
                            Message : in String;
                            Level   : in Syslog_Level_Type);

   --
   -- Increases the indentation for a log.
   --
   procedure Increase_Indent (Name : in String);

   --
   -- Increases the indentation for a log.
   --
   procedure Increase_Indent (Handle : in Syslog_Handle_Type);

   --
   -- Decreases the indentation for a log.
   --
   procedure Decrease_Indent (Name : in String);

   --
   -- Decreases the indentation for a log.
   --
   procedure Decrease_Indent (Handle : in Syslog_Handle_Type);

   --
   -- Resets the indentation for a log.
   --
   procedure Reset_Indent (Name : in String);

   --
   -- Resets the indentation for a log.
   --
   procedure Reset_Indent (Handle : in Syslog_Handle_Type);

   --
   -- Open a session log file with a particular priority.
   --
   function Open_Session (Name  : in String;
                          Level : in Syslog_Level_Type) return Syslog_Handle_Type;

   --
   -- Close a session log and append it's date to the mail log.
   --
   procedure Close_Session (Handle : in Syslog_Handle_Type);

   --
   -- Log a block of data as a hex dump.
   --
   procedure Log_Data (Name      : in String;
                       Level     : in Syslog_Level_Type;
                       Data      : in Integer;
                       Data_Size : in Integer;
                       Base      : in Address);

   --
   -- Log a block of data as a hex dump.
   --
   procedure Log_Data (Handle    : in Syslog_Handle_Type;
                       Level     : in Syslog_Level_Type;
                       Data      : in Integer;
                       Data_Size : in Integer;
                       Base      : in Address);

   --
   -- Decodes the errors returned by the stack.
   --
   function Read_ErrorMessage (Error_Number : in Integer) return String;

   --
   -- Flushes the names log and deallocates the space set aside for it.
   --
   procedure Log_Complete (Name : in String);

   --
   -- Flushes the names log and deallocates the space set aside for it.
   --
   procedure Log_Complete (Handle : in Syslog_Handle_Type);

end RASCAL.SysLog;
