text
stringlengths
0
234
Seps : constant String := " ";
Fields_Exception : exception;
begin
File_Line := SU.To_Unbounded_String (Get_Line (F));
loop
exit when SU.To_String (File_Line)'Length > 0 and then SU.To_String (File_Line) (1) /= '#';
File_Line := SU.To_Unbounded_String (Get_Line (F));
end loop;
Create (S => Fields,
From => SU.To_String (File_Line),
Separators => Seps,
Mode => Multiple);
if Positive (Slice_Count (Fields)) /= Expected then
Raise_Exception (Fields_Exception'Identity, "Expected to read" & Positive'Image (Expected) & " fields");
end if;
return Fields;
exception
when Fail: Fields_Exception =>
Put_Line (Exception_Message (Fail));
return Fields;
end Read_Fields;
begin
for Arg in 1 .. Argument_Count/2 loop
declare
A : Argument_Option;
begin
A := Argument_Option'Value (Argument(Arg*2-1));
case A is
when Argument_Option'(Verbose) =>
case Boolean_Flag'Value (Argument(Arg*2)) is
when Boolean_Flag'(true) =>
Verbose_Flag := TRUE;
Put_Line ("Verbose mode");
when others =>
Verbose_Flag := FALSE;
Put_Line ("Silent mode");
end case;
when Input =>
In_Filename := SU.To_Unbounded_String (Argument(Arg*2));
when Output =>
Out_Filename := SU.To_Unbounded_String (Argument(Arg*2));
when others =>
null;
end case;
exception
when Constraint_Error =>
Put_Line ("Wrong arguments");
OS_Exit(1);
Function Definition: procedure Free_Logger_Msg_Ptr is new Ada.Unchecked_Deallocation
Function Body: (Object => Logger_Message_Packet, Name => Logger_Message_Packet_Ptr);
function Format_Log_Level
(Use_Color : Boolean;
Log_Level : Log_Levels)
return Unbounded_String
is
Color_Prefix : Unbounded_String;
Log_Level_Str : Unbounded_String;
Now : constant Time := Clock;
begin
-- Add ANSI color codes if we're using color on Linux
if Use_Color
then
case Log_Level is
when EMERGERENCY =>
Color_Prefix := To_Unbounded_String (ANSI_Light_Red);
when ALERT =>
Color_Prefix := To_Unbounded_String (ANSI_Light_Red);
when CRITICAL =>
Color_Prefix := To_Unbounded_String (ANSI_Light_Red);
when ERROR =>
Color_Prefix := To_Unbounded_String (ANSI_Red);
when WARNING =>
Color_Prefix := To_Unbounded_String (ANSI_Light_Yellow);
when NOTICE =>
Color_Prefix := To_Unbounded_String (ANSI_Yellow);
when INFO =>
Color_Prefix := To_Unbounded_String (ANSI_Green);
when DEBUG =>
Color_Prefix := To_Unbounded_String (ANSI_Light_Blue);
end case;
Log_Level_Str :=
Color_Prefix & To_Unbounded_String (Log_Level'Image) & ANSI_Reset;
else
Log_Level_Str := To_Unbounded_String (Log_Level'Image);
end if;
return To_Unbounded_String
(Image (Date => Now) & " [" & To_String (Log_Level_Str) & "]");
end Format_Log_Level;