Codebase list libalog / ec597b6
Update to release 0.5.3 Adrian-Ken Rueegsegger 5 years ago
19 changed file(s) with 130 addition(s) and 99 deletion(s). Raw diff Collapse all Expand all
11 lib
22 obj
33 *.o
4 debian/patches/series
00 Alog Changelog
11 ==============
2
3 Version 0.5.3
4 -------------
5 .Additions and changes
6 - Add support for '*' wildcard
7 - Rework build logic
28
39 Version 0.5.2
410 -------------
1919 # MA 02110-1301 USA
2020 #
2121
22 # DESTDIR and PREFIX have their usual meanings.
2223 PREFIX ?= $(HOME)/libraries
24
2325 INSTALL = install
2426
2527 MAJOR = 0
2628 MINOR = 5
27 REVISION = 2
29 REVISION = 3
2830 VERSION = $(MAJOR).$(MINOR).$(REVISION)
2931 ALOG = libalog-$(VERSION)
3032 TARBALL = $(ALOG).tar.bz2
4850 # environment or on the command line.
4951 CFLAGS ?= -W -Wall -Werror -O3
5052 GNAT_BUILDER_FLAGS ?= -R -j$(NUM_CPUS)
51 GNATFLAGS ?= ${GNAT_BUILDER_FLAGS} -cargs ${ADAFLAGS}
53 GNATFLAGS ?= ${GNAT_BUILDER_FLAGS}
5254 # GMAKE_OPTS should not be overridden because -p is essential.
53 GMAKE_OPTS = -p ${GNATFLAGS} -margs
55 GMAKE_OPTS = -g -p ${GNATFLAGS} \
56 $(foreach v,ADAFLAGS CFLAGS CPPFLAGS LDFLAGS,"-X$(v)=$($(v))")
5457
5558 all: build_lib
5659
5760 tests: build_tests
5861 @$(OBJECTDIR)/test_runner
5962
60 build_lib:
61 @gprbuild $(GMAKE_OPTS) -Palog -XALOG_VERSION="$(VERSION)" \
62 -XLIBRARY_KIND="$(LIBRARY_KIND)" -XCFLAGS="$(CFLAGS)" \
63 -XLDFLAGS="$(LDFLAGS)" -cargs $(ADAFLAGS)
63 build_lib: build_lib_$(LIBRARY_KIND)
64 build_lib_dynamic:
65 @gprbuild $(GMAKE_OPTS) -Palog -XALOG_VERSION="$(VERSION)"
66 build_lib_static:
67 @gprbuild $(GMAKE_OPTS) -Palog -XALOG_VERSION=
6468
6569 build_tests:
66 @gprbuild $(GMAKE_OPTS) -Palog_tests -XALOG_BUILD="tests"
70 @gprbuild $(GMAKE_OPTS) -Palog_tests -XALOG_BUILD="tests" -XALOG_VERSION=
6771
6872 build_all: build_lib build_tests
6973
8185 install: install_lib install_$(LIBRARY_KIND)
8286
8387 install_lib: build_lib
84 @mkdir -p $(PREFIX)/include/alog
85 @mkdir -p $(PREFIX)/lib/alog
86 @mkdir -p $(PREFIX)/lib/gnat
87 $(INSTALL) -m 644 $(SOURCEDIR)/*.ad[bs] $(PREFIX)/include/alog
88 $(INSTALL) -m 444 $(ALI_FILES) $(PREFIX)/lib/alog
89 $(INSTALL) -m 644 $(GPR_FILE) $(PREFIX)/lib/gnat
88 @mkdir -p $(DESTDIR)$(PREFIX)/include/alog
89 @mkdir -p $(DESTDIR)$(PREFIX)/lib/alog
90 @mkdir -p $(DESTDIR)$(PREFIX)/lib/gnat
91 $(INSTALL) -m 644 $(SOURCEDIR)/*.ad[bs] $(DESTDIR)$(PREFIX)/include/alog
92 $(INSTALL) -m 444 $(ALI_FILES) $(DESTDIR)$(PREFIX)/lib/alog
93 $(INSTALL) -m 644 $(GPR_FILE) $(DESTDIR)$(PREFIX)/lib/gnat
9094
91 install_static:
92 $(INSTALL) -m 444 $(LIBDIR)/$(LIBRARY_KIND)/$(A_LIBRARY) $(PREFIX)/lib
95 install_static: $(DESTDIR)$(PREFIX)/lib
96 $(INSTALL) -m 444 $(LIBDIR)/$(LIBRARY_KIND)/$(A_LIBRARY) $<
9397
94 install_dynamic:
95 $(INSTALL) -m 444 $(LIBDIR)/$(LIBRARY_KIND)/$(SO_LIBRARY) $(PREFIX)/lib
96 @cd $(PREFIX)/lib && ln -sf $(SO_LIBRARY) libalog.so
98 install_dynamic: $(DESTDIR)$(PREFIX)/lib
99 $(INSTALL) -m 444 $(LIBDIR)/$(LIBRARY_KIND)/$(SO_LIBRARY) $<
100 @cd $(DESTDIR)$(PREFIX)/lib && ln -sf $(SO_LIBRARY) libalog.so
97101
98102 install_tests: build_tests
99 $(INSTALL) -v -d $(PREFIX)/tests
100 $(INSTALL) -m 755 $(OBJECTDIR)/test_runner $(PREFIX)/tests/
101 @cp -vr data $(PREFIX)/tests
103 $(INSTALL) -v -d $(DESTDIR)$(PREFIX)/tests
104 $(INSTALL) -m 755 $(OBJECTDIR)/test_runner $(DESTDIR)$(PREFIX)/tests/
105 @cp -vr data $(DESTDIR)$(PREFIX)/tests
106
107 $(DESTDIR)$(PREFIX)/lib:
108 @mkdir -p $@
102109
103110 cov:
104111 @mkdir -p $(COVDIR)
105112 @rm -f $(OBJECTDIR)/cov/*.gcda
106 @gprbuild $(GMAKE_OPTS) -Palog_tests -XALOG_BUILD="coverage"
113 @gprbuild $(GMAKE_OPTS) -Palog_tests -XALOG_BUILD="coverage" -XALOG_VERSION=
107114 @$(OBJECTDIR)/cov/test_runner || true
108115 @lcov -c -d $(OBJECTDIR)/cov/ -o $(OBJECTDIR)/cov/alog_tmp.info
109116 @lcov -e $(OBJECTDIR)/cov/alog_tmp.info "$(PWD)/src/*.adb" \
112119
113120 prof:
114121 @rm -f $(OBJECTDIR)/callgrind.*
115 gprbuild $(GMAKE_OPTS) -Palog_tests -XALOG_BUILD="profiling"
122 gprbuild $(GMAKE_OPTS) -Palog_tests -XALOG_BUILD="profiling" -XALOG_VERSION=
116123 valgrind -q --tool=callgrind \
117124 --callgrind-out-file=$(OBJECTDIR)/callgrind.out.%p $(OBJECTDIR)/profiler
118125 callgrind_annotate $(OBJECTDIR)/callgrind.* > $(OBJECTDIR)/profile.txt
1818 Release version
1919 ~~~~~~~~~~~~~~~
2020 The current release version of alog is available at
21 http://www.codelabs.ch/download/.
21 https://www.codelabs.ch/download/.
2222
2323 Verify a Release
2424 ~~~~~~~~~~~~~~~~
2525 To verify the integrity and authenticity of the distribution tarball, import
26 the key http://www.codelabs.ch/keys/0xBB793815pub.asc and type the following
26 the key https://www.codelabs.ch/keys/0xBB793815pub.asc and type the following
2727 command:
2828
2929 $ gpg --verify libalog-{version}.tar.bz2.sig
3636 ~~~~~~~~~~~~~~~~~~~
3737 The current development version of alog is available through its git repository:
3838
39 $ git clone http://git.codelabs.ch/git/alog.git
39 $ git clone https://git.codelabs.ch/git/alog.git
4040
4141 A browsable version of the repository is also available here:
42 http://git.codelabs.ch/?p=alog.git
42 https://git.codelabs.ch/?p=alog.git
4343
4444
4545 Installation
2121
2222 with "alog_common";
2323
24 project Alog is
24 library project Alog is
25
26 Alog_Version := External ("ALOG_VERSION");
27 -- Require an explicit setting for ALOG_VERSION.
28 -- Build a static library when it is empty,
29 -- else a relocatable library with the given shared object version.
2530
2631 for Languages use Alog_Common.Languages;
2732 for Source_Dirs use ("src");
28 for Object_Dir use "obj/lib/" & Alog_Common.Libtype;
2933 for Library_Name use "alog";
30 for Library_Dir use "lib/" & Alog_Common.Libtype;
31 for Library_Kind use Alog_Common.Libtype;
32 for Library_Version use "libalog.so." & Alog_Common.Version;
33 for Library_Options use External_As_List ("LDFLAGS", " ");
3434
35 package Compiler is
36 for Default_Switches ("C") use External_As_List ("CFLAGS", " ");
37 for Default_Switches ("ada") use Alog_Common.Compiler_Switches & "-gnatwe";
35 case Alog_Version is
36 when "" =>
37 for Library_Kind use "static";
38 when others =>
39 for Library_Kind use "dynamic";
40 for Library_Version use "libalog.so." & Alog_Version;
41 -- Start with LDFLAGS as it may contain options like --as-needed.
42 for Leading_Library_Options use Alog_Common.Ldflags;
43 end case;
44 for Object_Dir use "obj/lib/" & project'Library_Kind;
45 for Library_Dir use "lib/" & project'Library_Kind;
46
47 package Compiler extends Alog_Common.Compiler is
48 for Default_Switches ("Ada") use
49 Alog_Common.Compiler'Default_Switches ("Ada") & "-gnatwe";
3850 end Compiler;
3951
40 package Builder is
41 for Default_Switches ("ada") use Alog_Common.Builder_Switches;
42 end Builder;
43
4452 end Alog;
45
1919 -- MA 02110-1301 USA
2020 --
2121
22 project Alog_Common is
22 abstract project Alog_Common is
2323
2424 for Source_Dirs use ();
2525
26 Version := external ("ALOG_VERSION", "0.1");
27
28 type Lib_Type is ("static", "dynamic");
29 Libtype : Lib_Type := external ("LIBRARY_KIND", "static");
26 Adaflags := External_As_List ("ADAFLAGS", " ");
27 Cflags := External_As_List ("CFLAGS", " ");
28 Cppflags := External_As_List ("CPPFLAGS", " ");
29 Ldflags := External_As_List ("LDFLAGS", " ");
3030
3131 Languages := ("Ada", "C");
3232
33 Compiler_Switches := ("-gnatygAdISuxo",
34 "-gnatVa",
35 "-gnat05",
36 "-gnatwal",
37 "-gnatf",
38 "-fstack-check",
39 "-gnato");
33 package Compiler is
34 for Default_Switches ("Ada") use
35 ("-gnatygAdISuxo",
36 "-gnatVa",
37 "-gnatwal",
38 "-gnatf",
39 "-fstack-check",
40 "-gnato")
41 & Adaflags;
42 for Default_Switches ("C") use Cflags & Cppflags;
43 end Compiler;
4044
41 Builder_Switches := ("-g");
45 package Binder is
46 for Default_Switches ("Ada") use ("-E");
47 end Binder;
4248
43 Binder_Switches := ("-E");
49 package Linker is
50 -- Template for linking an executable.
51 -- Start with LDFLAGS as it may contain options like --as-needed.
52 for Leading_Switches ("Ada") use Ldflags;
53 end Linker;
4454
4555 end Alog_Common;
46
3030 for Languages use Alog_Common.Languages;
3131 for Source_Dirs use ("src", "tests");
3232
33 Compiler_Switches := Alog_Common.Compiler_Switches;
33 Compiler_Switches := ();
3434 Linker_Switches := ();
3535
3636 case Build is
5252
5353 end case;
5454
55 package Compiler is
56 for Default_Switches ("ada") use Compiler_Switches;
55 package Compiler extends Alog_Common.Compiler is
56 for Default_Switches ("Ada") use
57 Alog_Common.Compiler'Default_Switches ("Ada") & Compiler_Switches;
5758 end Compiler;
5859
59 package Linker is
60 for Default_Switches ("ada") use Linker_Switches;
60 package Linker extends Alog_Common.Linker is
61 for Default_Switches ("Ada") use
62 Alog_Common.Linker'Default_Switches ("Ada") & Linker_Switches;
6163 end Linker;
6264
63 package Builder is
64 for Default_Switches ("ada") use Alog_Common.Builder_Switches;
65 end Builder;
66
67 package Binder is
68 for Default_Switches ("ada") use Alog_Common.Binder_Switches;
69 end Binder;
65 package Binder renames Alog_Common.Binder;
7066
7167 end Alog_Tests;
72
44
55 * link:CHANGELOG.html[CHANGELOG]
66
7 * http://www.codelabs.ch/download/[Download]
7 * https://www.codelabs.ch/download/[Download]
88
99 Overview
1010 --------
115115 Browse the source
116116 -----------------
117117 - You can browse the Alog source code with gitweb
118 http://git.codelabs.ch/?p=alog.git[here].
118 https://git.codelabs.ch/?p=alog.git[here].
119119
120120
121121 Licence
122122 -------
123123 --------------------------------------------------------------------------------
124 Copyright (C) 2008-2014 Reto Buerki
125 Copyright (C) 2008-2014 Adrian-Ken Rueegsegger
124 Copyright (C) 2008-2018 Reto Buerki
125 Copyright (C) 2008-2018 Adrian-Ken Rueegsegger
126126
127127 Alog is free software; you can redistribute it and/or modify it under the terms
128128 of the GNU Lesser General Public License as published by the Free Software
2121
2222 all: build_examples
2323
24 # C compilations may happen if the library is updated.
2425 build_examples:
25 @gprbuild -p -Palog_examples
26 @gprbuild -p -Palog_examples -XALOG_VERSION= \
27 $(foreach v,ADAFLAGS CFLAGS CPPFLAGS LDFLAGS,"-X$(v)=$($(v))")
2628
2729 clean:
2830 @rm -rf obj
2828 for Object_Dir use "obj";
2929 for Main use ("logger_example1.adb", "facility_example1.adb", "policy_example1.adb", "policy_example2.adb", "syslog_example1.adb");
3030
31 package Compiler is
32 for Default_Switches ("ada") use Alog_Common.Compiler_Switches;
33 end Compiler;
34
35 package Builder is
36 for Default_Switches ("ada") use ("-g");
37 end Builder;
31 package Compiler renames Alog_Common.Compiler;
32 package Binder renames Alog_Common.Binder;
33 package Linker renames Alog_Common.Linker;
3834
3935 end Alog_Examples;
40
2828 -- for Main use ("example");
2929 -- end Example;
3030
31 project Alog is
31 library project Alog is
3232 for Source_Dirs use ("../../include/alog");
3333 for Library_Name use "alog";
3434 for Library_Dir use "../../lib";
8181
8282 -- Set logfile name and pointer to newly created file.
8383
84 Facility.Log_File_Name := To_Bounded_String (Path);
84 Facility.Log_File_Name := BS_Path.To_Bounded_String (Path);
8585
8686 -- Unchecked_Access is needed here since we use a pointer which is
8787 -- defined externaly in the Text_IO library.
7171 -- Reference to actual log file. Default is Standard_Output.
7272
7373 Log_File_Name : BS_Path.Bounded_String :=
74 To_Bounded_String ("none");
74 BS_Path.To_Bounded_String ("none");
7575 -- File name of log file.
7676 end record;
7777
124124 -- called by Logger instances when detaching Facilities or when the logger
125125 -- object gets out of scope.
126126
127 package BS_Path is new Generic_Bounded_Length (Max_Path_Length);
128 use BS_Path;
129 -- Bounded string with length Max_Path_Length. Used in methods which
130 -- involve filesystem operations.
131
132127 Invalid_Timestamp_Format : exception;
133128
134129 private
130
131 package BS_Path is new Generic_Bounded_Length (Max => Max_Path_Length);
132 -- Bounded string with length Max_Path_Length. Used in methods which
133 -- involve filesystem operations.
135134
136135 type Instance is abstract tagged limited record
137136 Name : Unbounded_String
125125 end loop;
126126 end Find_Closest_Match;
127127
128 return No_Element;
128 -- Try all-wildcard as last option.
129
130 return Map.Find (Key => (1 => Wildcard));
129131 end Lookup;
130132
131133 end Alog.Maps;
7171
7272 private
7373
74 use type Alog.Log_Request.Instance;
75
7674 package List_Of_Log_Requests_Package is
7775 new Ada.Containers.Doubly_Linked_Lists
78 (Element_Type => Log_Request.Instance);
76 (Element_Type => Log_Request.Instance,
77 "=" => Log_Request."=");
7978
8079 package LOLRP renames List_Of_Log_Requests_Package;
8180
104104 procedure Timestamp_Format_Setter
105105 is
106106 use Ada.Calendar;
107 use Ada.Calendar.Time_Zones;
108107
109108 F : File_Descriptor.Instance;
110109
176176 Assert (Condition => Position = Maps.No_Element,
177177 Message => "No_Element expected");
178178 end;
179
180 declare
181 use type Maps.Cursor;
182
183 Position : Maps.Cursor;
184 begin
185 Map.Insert (Key => "*",
186 Item => Debug);
187 Position := Map.Lookup (Key => "Bar.Bar");
188 Assert (Condition => Position /= Maps.No_Element,
189 Message => "No loglevel for '*' found");
190 Assert (Condition => Maps.Element (Position => Position) = Debug,
191 Message => "Loglevel for '*' not debug");
192 end;
179193 end Wildcard_Lookup;
180194
181195 end Maps_Tests;
326326 -------------------------------------------------------------------------
327327
328328 procedure Iterate_Facilities_Exceptions is
329 use Ada.Exceptions;
330
331329 Log : Tasked_Logger.Instance (Init => False);
332330 Facility1 : constant Facilities.Handle :=
333331 new Facilities.File_Descriptor.Instance;