File: logger_example1.adb

package info (click to toggle)
libalog 0.6.2-7.1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 784 kB
  • sloc: ada: 4,353; makefile: 99; sh: 18; ansic: 5
file content (30 lines) | stat: -rw-r--r-- 918 bytes parent folder | download | duplicates (8)
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
with Alog.Logger;
with Alog.Facilities.File_Descriptor;

use Alog;

--  Alog logger example.
procedure Logger_Example1 is
   --  Initialize logger instance with default file descriptor facility
   --  (logs to stdout).
   Log : Logger.Instance (Init => True);
begin
   --  Write a message with loglevel 'Info' to stdout.
   Log.Log_Message
     (Level => Info,
      Msg   => "This is a testmessage from Alog logger");

   Attach_FD_Facility :
   declare
      FD : constant Facilities.File_Descriptor.Handle :=
        new Facilities.File_Descriptor.Instance;
   begin
      FD.Set_Logfile (Path => "/tmp/alog.log");
      Log.Attach_Facility (Facility => Facilities.Handle (FD));

      --  Log a message to file and stdout.
      Log.Log_Message (Source => "Example",
                       Level  => Warning,
                       Msg    => "Another testmessage");
   end Attach_FD_Facility;
end Logger_Example1;