1. -- 
  2. --  Copyright (c) 2009, 
  3. --  Reto Buerki, Adrian-Ken Rueegsegger 
  4. --  secunet SwissIT AG 
  5. -- 
  6. --  This file is part of Alog. 
  7. -- 
  8. --  Alog is free software; you can redistribute it and/or modify 
  9. --  it under the terms of the GNU Lesser General Public License as published 
  10. --  by the Free Software Foundation; either version 2.1 of the License, or 
  11. --  (at your option) any later version. 
  12. -- 
  13. --  Alog is distributed in the hope that it will be useful, 
  14. --  but WITHOUT ANY WARRANTY; without even the implied warranty of 
  15. --  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
  16. --  GNU Lesser General Public License for more details. 
  17. -- 
  18. --  You should have received a copy of the GNU Lesser General Public License 
  19. --  along with Alog; if not, write to the Free Software 
  20. --  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, 
  21. --  MA  02110-1301  USA 
  22. -- 
  23.  
  24. with Alog.Maps; 
  25.  
  26. --  Logging policy database package. This DB stores logging policies. Policies 
  27. --  in the database are used inside the framework for logging decisions. 
  28. package Alog.Policy_DB is 
  29.  
  30.    Alog_Default_Level : constant Log_Level := Debug; 
  31.    --  Framework default loglevel. 
  32.  
  33.    procedure Set_Default_Loglevel (Level : Log_Level); 
  34.    --  Set given loglevel as default loglevel. 
  35.  
  36.    function Get_Default_Loglevel return Log_Level; 
  37.    --  Return current default loglevel. 
  38.  
  39.    procedure Set_Loglevel 
  40.      (Identifier : String; 
  41.       Level      : Log_Level); 
  42.    --  Set given loglevel for specified identifier string. If the identifier is 
  43.    --  already present the loglevel is updated. Identifier strings are 
  44.    --  case-sensitive. 
  45.    -- 
  46.    --  Use wildcards to specify a loglevel for a range of identifiers. 
  47.    --  Identifier hierarchies are separated by dots, the wildcard is '*'. The 
  48.    --  following example sets a Debug loglevel for all log-identifiers in 
  49.    --  Foo.Bar (including Foo.Bar). 
  50.    -- 
  51.    --  Example: 
  52.    --     Foo.Bar.* = Debug 
  53.    -- 
  54.    --  Direct matches take precedence over wildcard matches. In the following 
  55.    --  example the loglevel for identifier 'Foo.Bar' is explicitly set to Info. 
  56.    -- 
  57.    --  Example: 
  58.    --     Foo.Bar   = Info 
  59.    --     Foo.Bar.* = Debug 
  60.  
  61.    procedure Set_Loglevel (Identifiers : Maps.Wildcard_Level_Map); 
  62.    --  Apply loglevels for identifiers stored in map. 
  63.  
  64.    function Get_Loglevel (Identifier : String) return Log_Level; 
  65.    --  Return loglevel for given identifier string. Raises No_Ident_Loglevel 
  66.    --  exception if no entry for given identifier is found (exact match only, no 
  67.    --  wildcard lookup). 
  68.  
  69.    function Lookup (Identifier : String) return Log_Level; 
  70.    --  Return loglevel for given identifier string. Returns the closest match, 
  71.    --  if no associated loglevel is found the default loglevel is returned. 
  72.  
  73.    procedure Reset; 
  74.    --  Reset the logging policy database to the initial state. 
  75.  
  76.    function Accept_Src 
  77.      (Identifier : String := ""; 
  78.       Level      : Log_Level) 
  79.       return Boolean; 
  80.    --  Returns True if the given loglevel is accepted for a source identifier. 
  81.    --  If no identifier is given, the loglevel is verified against the default 
  82.    --  loglevel. 
  83.  
  84.    function Accept_Dst 
  85.      (Identifier : String; 
  86.       Level      : Log_Level) 
  87.       return Boolean; 
  88.    --  Returns True if the given loglevel is accepted for a destination 
  89.    --  identifier. If no match for the given identifier is found True is 
  90.    --  returned. 
  91.  
  92.    No_Ident_Loglevel : exception; 
  93.    --  Will be raised if loglevel is not found for a requested identifier. 
  94.  
  95. end Alog.Policy_DB;