mold_lib_2.2.1_9048c6c2/src/impl/log_exceptions.adb

 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
-------------------------------------------------------------------------------
--
--  Mold_Lib - Meta-variable Operations for Lean Development
--  Copyright (c) 2023 Francesc Rocher <francesc.rocher@gmail.com>
--  SPDX-License-Identifier: MIT
--
-------------------------------------------------------------------------------

with Simple_Logging;

package body Log_Exceptions is

   package Log renames Simple_Logging;

   -------------------
   -- Log_Exception --
   -------------------

   --!pp off
   procedure Log_Exception
   (
      Occurrence : Ada.Exceptions.Exception_Occurrence;
      Message    : String := "";
      Location   : String := GNAT.Source_Info.Source_Location;
      Entity     : String := GNAT.Source_Info.Enclosing_Entity
   )
   --!pp on

   is
      use Ada.Exceptions;
   begin
      Log.Error
        ("(EXCEPTION " & Exception_Name (Occurrence) & "): " & Message &
         (if Message /= "" then "," else "") & " '" &
         Exception_Message (Occurrence) & "', in " & Location & " (" & Entity &
         ")");
   end Log_Exception;

end Log_Exceptions;