text
stringlengths 0
234
|
|---|
function Create_String_From_Components
|
(Components : Component_Vector.Vector)
|
return Unbounded_String
|
is
|
Components_String : Unbounded_String;
|
procedure Component_To_String (c : Component_Vector.Cursor) is
|
Scratch_String : Unbounded_String;
|
begin
|
Scratch_String := Components (c);
|
Components_String := Components_String & "[" & Scratch_String & "]";
|
end Component_To_String;
|
begin
|
-- If there's no component, just leave it blank
|
if Components.Length = 0
|
then
|
return To_Unbounded_String ("");
|
end if;
|
Components.Iterate (Component_To_String'Access);
|
return Components_String;
|
end Create_String_From_Components;
|
protected body Logger_Queue_Type is
|
-- Handles queue of packets for the logger thread
|
entry Add_Packet (Queue : Logger_Message_Packet_Ptr) when True is
|
begin
|
Queued_Packets.Append (Queue);
|
end Add_Packet;
|
entry Get (Queue : out Logger_Message_Packet_Ptr)
|
when Queued_Packets.Length > 0 is
|
begin
|
Queue := Queued_Packets.First_Element;
|
Queued_Packets.Delete_First;
|
end Get;
|
entry Count (Count : out Integer) when True is
|
begin
|
Count := Integer (Queued_Packets.Length);
|
end Count;
|
entry Empty when True is
|
begin
|
declare
|
procedure Dump_Vector_Data
|
(c : Logger_Message_Packet_Vector.Cursor)
|
is
|
begin
|
Free_Logger_Msg_Ptr (Queued_Packets (c));
|
end Dump_Vector_Data;
|
begin
|
Queued_Packets.Iterate (Dump_Vector_Data'access);
|
Function Definition: procedure Process_Queue is
|
Function Body: procedure Print_Messages (c : Log_Message_Vector.Cursor) is
|
Current_Msg : constant Log_Message_Record :=
|
Log_Message_Vector.Element (c);
|
begin
|
-- This is so ugly :(
|
if Log_Levels'Enum_Rep (Logger_Cfg.Log_Level) >=
|
Log_Levels'Enum_Rep (Current_Msg.Log_Level)
|
then
|
Msg_String :=
|
Format_Log_Level
|
(Logger_Cfg.Use_Color, Current_Msg.Log_Level);
|
Msg_String :=
|
Msg_String &
|
Create_String_From_Components (Current_Msg.Component);
|
Msg_String := Msg_String & " " & Current_Msg.Message;
|
Put_Line (To_String (Msg_String));
|
end if;
|
end Print_Messages;
|
begin
|
Logger_Queue.Count (Queues_To_Process);
|
while Queues_To_Process > 0
|
loop
|
Logger_Queue.Get (Current_Queue);
|
-- Get a local copy and then empty it; we don't care past that
|
-- point
|
if Current_Queue /= null
|
then
|
Current_Queue.Get_All_And_Empty (Msg_Packets);
|
Msg_Packets.Iterate (Print_Messages'Access);
|
Free_Logger_Msg_Ptr (Current_Queue);
|
end if;
|
Logger_Queue.Count (Queues_To_Process);
|
end loop;
|
exception
|
-- Not sure if there's a better way to do this, but avoids a race
|
-- condition
|
when Constraint_Error =>
|
begin
|
null;
|
Function Definition: function To_Domain_Section is new Ada.Unchecked_Conversion
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.