Better logging
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
with Ada.Directories;
|
||||
with GNAT.OS_Lib;
|
||||
|
||||
package body Alire.OS_Lib is
|
||||
@@ -27,8 +26,12 @@ package body Alire.OS_Lib is
|
||||
-- FIXME: memory leaks
|
||||
function Spawn (Command : String;
|
||||
Arguments : String) return Integer is
|
||||
(Spawn (Locate_In_Path (Command),
|
||||
Argument_String_To_List (Arguments).all));
|
||||
begin
|
||||
Log ("Spawning: " & Command & " " & Arguments, Verbose);
|
||||
return
|
||||
(Spawn (Locate_In_Path (Command),
|
||||
Argument_String_To_List (Arguments).all));
|
||||
end Spawn;
|
||||
|
||||
-----------
|
||||
-- Spawn --
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
with Ada.Directories;
|
||||
with Ada.Finalization;
|
||||
|
||||
package Alire.OS_Lib is
|
||||
@@ -16,6 +17,10 @@ package Alire.OS_Lib is
|
||||
|
||||
function Enter_Folder (Path : String) return Folder_Guard;
|
||||
|
||||
function "/" (L, R : String) return String is
|
||||
(Ada.Directories.Compose (L, R));
|
||||
-- Shorthand for path composition
|
||||
|
||||
private
|
||||
|
||||
type Folder_Guard (Original_Len : Positive) is new Ada.Finalization.Limited_Controlled with record
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
with GNAT.IO;
|
||||
|
||||
package body Alire is
|
||||
|
||||
procedure Log (S : String; Level : Verbosities := Terse) is
|
||||
begin
|
||||
if Level >= Verbosity then
|
||||
GNAT.IO.Put_Line
|
||||
((case Level is
|
||||
when Terse => "",
|
||||
when Verbose => ": ",
|
||||
when Debug => "+++ ") & S);
|
||||
end if;
|
||||
end Log;
|
||||
|
||||
end Alire;
|
||||
+9
-6
@@ -1,7 +1,5 @@
|
||||
private with Ada.Containers.Indefinite_Holders;
|
||||
|
||||
private with GNAT.IO; -- For debugging purposes, FIXME getting rid of it and using some proper Trace lib
|
||||
|
||||
with Semantic_Versioning;
|
||||
|
||||
package Alire with Preelaborate is
|
||||
@@ -38,6 +36,14 @@ package Alire with Preelaborate is
|
||||
|
||||
function Version (M : Milestone) return Semantic_Versioning.Version;
|
||||
|
||||
-- LOGGING --
|
||||
|
||||
type Verbosities is (Debug, Verbose, Terse);
|
||||
|
||||
Verbosity : Verbosities := Terse;
|
||||
|
||||
procedure Log (S : String; Level : Verbosities := Terse);
|
||||
|
||||
private
|
||||
|
||||
use all type Semantic_Versioning.Version;
|
||||
@@ -72,9 +78,6 @@ private
|
||||
|
||||
function Project (M : Milestone) return Project_Name is (M.Name);
|
||||
|
||||
function Version (M : Milestone) return Semantic_Versioning.Version is (M.Version);
|
||||
|
||||
|
||||
procedure Log (S : String) renames GNAT.IO.Put_Line;
|
||||
function Version (M : Milestone) return Semantic_Versioning.Version is (M.Version);
|
||||
|
||||
end Alire;
|
||||
|
||||
Reference in New Issue
Block a user