This file is indexed.

/usr/share/ada/adainclude/alog/alog-active_logger.adb is in libalog0.4.1-base-dev 0.4.1-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
--
--  Copyright (c) 2009-2011,
--  Reto Buerki, Adrian-Ken Rueegsegger
--
--  This file is part of Alog.
--
--  Alog 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.
--
--  Alog 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 Alog; if not, write to the Free Software
--  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
--  MA  02110-1301  USA
--

with Ada.Task_Identification;

with Alog.Log_Request;

package body Alog.Active_Logger is

   -------------------------------------------------------------------------

   procedure All_Done (Logger : in out Instance) is
   begin
      Logger.Message_Queue.All_Done;
   end All_Done;

   -------------------------------------------------------------------------

   procedure Attach_Default_Facility (Logger : in out Instance)
   is
   begin
      Logger.Backend.Attach_Default_Facility;
   end Attach_Default_Facility;

   -------------------------------------------------------------------------

   procedure Attach_Facility
     (Logger   : in out Instance;
      Facility :        Facilities.Handle)
   is
   begin
      Logger.Backend.Attach_Facility (Facility);
   end Attach_Facility;

   -------------------------------------------------------------------------

   procedure Attach_Transform
     (Logger    : in out Instance;
      Transform :        Transforms.Handle)
   is
   begin
      Logger.Backend.Attach_Transform (Transform);
   end Attach_Transform;

   -------------------------------------------------------------------------

   procedure Clear (Logger : in out Instance) is
   begin
      Logger.Backend.Clear;
   end Clear;

   -------------------------------------------------------------------------

   procedure Detach_Default_Facility (Logger : in out Instance)
   is
   begin
      Logger.Backend.Detach_Default_Facility;
   end Detach_Default_Facility;

   -------------------------------------------------------------------------

   procedure Detach_Facility
     (Logger : in out Instance;
      Name   :        String)
   is
   begin
      Logger.Backend.Detach_Facility (Name);
   end Detach_Facility;

   -------------------------------------------------------------------------

   procedure Detach_Transform
     (Logger : in out Instance;
      Name   :        String)
   is
   begin
      Logger.Backend.Detach_Transform (Name);
   end Detach_Transform;

   -------------------------------------------------------------------------

   function Facility_Count (Logger : Instance) return Natural is
      F_Count : Natural;
   begin
      Logger.Backend.Facility_Count (Count => F_Count);
      return F_Count;
   end Facility_Count;

   -------------------------------------------------------------------------

   procedure Finalize (Helper : in out Shutdown_Helper) is
   begin
      Helper.Logger.Shutdown;
   end Finalize;

   -------------------------------------------------------------------------

   function Get_Queue_Length (Logger : Instance) return Natural is
   begin
      return Logger.Message_Queue.Length;
   end Get_Queue_Length;

   -------------------------------------------------------------------------

   function Is_Terminated (Logger : Instance) return Boolean is
   begin
      return Logger.Backend'Terminated
        and then Logger.Logger_Task'Terminated;
   end Is_Terminated;

   -------------------------------------------------------------------------

   procedure Iterate
     (Logger  : in out Instance;
      Process :        Tasked_Logger.Facility_Update_Handle)
   is
   begin
      Logger.Backend.Iterate (Process);
   end Iterate;

   -------------------------------------------------------------------------

   procedure Log_Message
     (Logger : in out Instance;
      Source :        String := "";
      Level  :        Log_Level;
      Msg    :        String)
   is
   begin
      Logger.Message_Queue.Put
        (Element => Log_Request.Create
           (ID      => Ada.Task_Identification.Current_Task,
            Source  => Source,
            Level   => Level,
            Message => Msg));
   end Log_Message;

   -------------------------------------------------------------------------

   procedure Set_Except_Handler
     (Logger : Instance;
      Proc   : Exceptions.Exception_Handler)
   is
   begin
      Logger.Backend.Set_Except_Handler (Proc => Proc);
   end Set_Except_Handler;

   -------------------------------------------------------------------------

   procedure Shutdown
     (Logger : in out Instance;
      Flush  :        Boolean := True)
   is
   begin
      if Logger.Is_Terminated then
         return;
      end if;

      if Flush then
         Logger.Message_Queue.All_Done;
      end if;

      Logger.Clear;
      Logger.Trigger.Shutdown;
      Logger.Backend.Shutdown;
   end Shutdown;

   -------------------------------------------------------------------------

   function Transform_Count (Logger : Instance) return Natural is
      T_Count : Natural;
   begin
      Logger.Backend.Transform_Count (Count => T_Count);
      return T_Count;
   end Transform_Count;

   -------------------------------------------------------------------------

   procedure Update
     (Logger  : in out Instance;
      Name    :        String;
      Process :        Tasked_Logger.Facility_Update_Handle)
   is
   begin
      Logger.Backend.Update (Name    => Name,
                             Process => Process);
   end Update;

   -------------------------------------------------------------------------

   protected body Trigger_Type is

      ----------------------------------------------------------------------

      procedure Shutdown is
      begin
         Shutdown_Requested := True;
      end Shutdown;

      ----------------------------------------------------------------------

      entry Stop when Shutdown_Requested is
      begin
         null;
      end Stop;

   end Trigger_Type;

   -------------------------------------------------------------------------

   task body Logging_Task is
   begin
      select
         Parent.Trigger.Stop;
      then abort
         Log_Loop :
         loop
            declare
               Current_Request : Log_Request.Instance;
            begin
               Parent.Message_Queue.Get
                 (Element => Current_Request);

               Parent.Backend.Log_Message
                 (Source => Current_Request.Get_Source,
                  Level  => Current_Request.Get_Log_Level,
                  Msg    => Current_Request.Get_Message,
                  Caller => Current_Request.Get_Caller_ID);

               Parent.Message_Queue.Done;

            exception
               when Program_Error =>

                  --  The Queue has terminated, let's shutdown.

                  exit Log_Loop;

               when others =>

                  --  Ignore other errors and resume normal operation.

                  null;
            end;
         end loop Log_Loop;
      end select;

   end Logging_Task;

end Alog.Active_Logger;