Update to release 0.5.3
Adrian-Ken Rueegsegger
5 years ago
0 | 0 | Alog Changelog |
1 | 1 | ============== |
2 | ||
3 | Version 0.5.3 | |
4 | ------------- | |
5 | .Additions and changes | |
6 | - Add support for '*' wildcard | |
7 | - Rework build logic | |
2 | 8 | |
3 | 9 | Version 0.5.2 |
4 | 10 | ------------- |
19 | 19 | # MA 02110-1301 USA |
20 | 20 | # |
21 | 21 | |
22 | # DESTDIR and PREFIX have their usual meanings. | |
22 | 23 | PREFIX ?= $(HOME)/libraries |
24 | ||
23 | 25 | INSTALL = install |
24 | 26 | |
25 | 27 | MAJOR = 0 |
26 | 28 | MINOR = 5 |
27 | REVISION = 2 | |
29 | REVISION = 3 | |
28 | 30 | VERSION = $(MAJOR).$(MINOR).$(REVISION) |
29 | 31 | ALOG = libalog-$(VERSION) |
30 | 32 | TARBALL = $(ALOG).tar.bz2 |
48 | 50 | # environment or on the command line. |
49 | 51 | CFLAGS ?= -W -Wall -Werror -O3 |
50 | 52 | GNAT_BUILDER_FLAGS ?= -R -j$(NUM_CPUS) |
51 | GNATFLAGS ?= ${GNAT_BUILDER_FLAGS} -cargs ${ADAFLAGS} | |
53 | GNATFLAGS ?= ${GNAT_BUILDER_FLAGS} | |
52 | 54 | # 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))") | |
54 | 57 | |
55 | 58 | all: build_lib |
56 | 59 | |
57 | 60 | tests: build_tests |
58 | 61 | @$(OBJECTDIR)/test_runner |
59 | 62 | |
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= | |
64 | 68 | |
65 | 69 | build_tests: |
66 | @gprbuild $(GMAKE_OPTS) -Palog_tests -XALOG_BUILD="tests" | |
70 | @gprbuild $(GMAKE_OPTS) -Palog_tests -XALOG_BUILD="tests" -XALOG_VERSION= | |
67 | 71 | |
68 | 72 | build_all: build_lib build_tests |
69 | 73 | |
81 | 85 | install: install_lib install_$(LIBRARY_KIND) |
82 | 86 | |
83 | 87 | 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 | |
90 | 94 | |
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) $< | |
93 | 97 | |
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 | |
97 | 101 | |
98 | 102 | 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 $@ | |
102 | 109 | |
103 | 110 | cov: |
104 | 111 | @mkdir -p $(COVDIR) |
105 | 112 | @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= | |
107 | 114 | @$(OBJECTDIR)/cov/test_runner || true |
108 | 115 | @lcov -c -d $(OBJECTDIR)/cov/ -o $(OBJECTDIR)/cov/alog_tmp.info |
109 | 116 | @lcov -e $(OBJECTDIR)/cov/alog_tmp.info "$(PWD)/src/*.adb" \ |
112 | 119 | |
113 | 120 | prof: |
114 | 121 | @rm -f $(OBJECTDIR)/callgrind.* |
115 | gprbuild $(GMAKE_OPTS) -Palog_tests -XALOG_BUILD="profiling" | |
122 | gprbuild $(GMAKE_OPTS) -Palog_tests -XALOG_BUILD="profiling" -XALOG_VERSION= | |
116 | 123 | valgrind -q --tool=callgrind \ |
117 | 124 | --callgrind-out-file=$(OBJECTDIR)/callgrind.out.%p $(OBJECTDIR)/profiler |
118 | 125 | callgrind_annotate $(OBJECTDIR)/callgrind.* > $(OBJECTDIR)/profile.txt |
18 | 18 | Release version |
19 | 19 | ~~~~~~~~~~~~~~~ |
20 | 20 | The current release version of alog is available at |
21 | http://www.codelabs.ch/download/. | |
21 | https://www.codelabs.ch/download/. | |
22 | 22 | |
23 | 23 | Verify a Release |
24 | 24 | ~~~~~~~~~~~~~~~~ |
25 | 25 | 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 | |
27 | 27 | command: |
28 | 28 | |
29 | 29 | $ gpg --verify libalog-{version}.tar.bz2.sig |
36 | 36 | ~~~~~~~~~~~~~~~~~~~ |
37 | 37 | The current development version of alog is available through its git repository: |
38 | 38 | |
39 | $ git clone http://git.codelabs.ch/git/alog.git | |
39 | $ git clone https://git.codelabs.ch/git/alog.git | |
40 | 40 | |
41 | 41 | 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 | |
43 | 43 | |
44 | 44 | |
45 | 45 | Installation |
21 | 21 | |
22 | 22 | with "alog_common"; |
23 | 23 | |
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. | |
25 | 30 | |
26 | 31 | for Languages use Alog_Common.Languages; |
27 | 32 | for Source_Dirs use ("src"); |
28 | for Object_Dir use "obj/lib/" & Alog_Common.Libtype; | |
29 | 33 | 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", " "); | |
34 | 34 | |
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"; | |
38 | 50 | end Compiler; |
39 | 51 | |
40 | package Builder is | |
41 | for Default_Switches ("ada") use Alog_Common.Builder_Switches; | |
42 | end Builder; | |
43 | ||
44 | 52 | end Alog; |
45 |
19 | 19 | -- MA 02110-1301 USA |
20 | 20 | -- |
21 | 21 | |
22 | project Alog_Common is | |
22 | abstract project Alog_Common is | |
23 | 23 | |
24 | 24 | for Source_Dirs use (); |
25 | 25 | |
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", " "); | |
30 | 30 | |
31 | 31 | Languages := ("Ada", "C"); |
32 | 32 | |
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; | |
40 | 44 | |
41 | Builder_Switches := ("-g"); | |
45 | package Binder is | |
46 | for Default_Switches ("Ada") use ("-E"); | |
47 | end Binder; | |
42 | 48 | |
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; | |
44 | 54 | |
45 | 55 | end Alog_Common; |
46 |
30 | 30 | for Languages use Alog_Common.Languages; |
31 | 31 | for Source_Dirs use ("src", "tests"); |
32 | 32 | |
33 | Compiler_Switches := Alog_Common.Compiler_Switches; | |
33 | Compiler_Switches := (); | |
34 | 34 | Linker_Switches := (); |
35 | 35 | |
36 | 36 | case Build is |
52 | 52 | |
53 | 53 | end case; |
54 | 54 | |
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; | |
57 | 58 | end Compiler; |
58 | 59 | |
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; | |
61 | 63 | end Linker; |
62 | 64 | |
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; | |
70 | 66 | |
71 | 67 | end Alog_Tests; |
72 |
4 | 4 | |
5 | 5 | * link:CHANGELOG.html[CHANGELOG] |
6 | 6 | |
7 | * http://www.codelabs.ch/download/[Download] | |
7 | * https://www.codelabs.ch/download/[Download] | |
8 | 8 | |
9 | 9 | Overview |
10 | 10 | -------- |
115 | 115 | Browse the source |
116 | 116 | ----------------- |
117 | 117 | - 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]. | |
119 | 119 | |
120 | 120 | |
121 | 121 | Licence |
122 | 122 | ------- |
123 | 123 | -------------------------------------------------------------------------------- |
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 | |
126 | 126 | |
127 | 127 | Alog is free software; you can redistribute it and/or modify it under the terms |
128 | 128 | of the GNU Lesser General Public License as published by the Free Software |
21 | 21 | |
22 | 22 | all: build_examples |
23 | 23 | |
24 | # C compilations may happen if the library is updated. | |
24 | 25 | build_examples: |
25 | @gprbuild -p -Palog_examples | |
26 | @gprbuild -p -Palog_examples -XALOG_VERSION= \ | |
27 | $(foreach v,ADAFLAGS CFLAGS CPPFLAGS LDFLAGS,"-X$(v)=$($(v))") | |
26 | 28 | |
27 | 29 | clean: |
28 | 30 | @rm -rf obj |
28 | 28 | for Object_Dir use "obj"; |
29 | 29 | for Main use ("logger_example1.adb", "facility_example1.adb", "policy_example1.adb", "policy_example2.adb", "syslog_example1.adb"); |
30 | 30 | |
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; | |
38 | 34 | |
39 | 35 | end Alog_Examples; |
40 |
28 | 28 | -- for Main use ("example"); |
29 | 29 | -- end Example; |
30 | 30 | |
31 | project Alog is | |
31 | library project Alog is | |
32 | 32 | for Source_Dirs use ("../../include/alog"); |
33 | 33 | for Library_Name use "alog"; |
34 | 34 | for Library_Dir use "../../lib"; |
81 | 81 | |
82 | 82 | -- Set logfile name and pointer to newly created file. |
83 | 83 | |
84 | Facility.Log_File_Name := To_Bounded_String (Path); | |
84 | Facility.Log_File_Name := BS_Path.To_Bounded_String (Path); | |
85 | 85 | |
86 | 86 | -- Unchecked_Access is needed here since we use a pointer which is |
87 | 87 | -- defined externaly in the Text_IO library. |
71 | 71 | -- Reference to actual log file. Default is Standard_Output. |
72 | 72 | |
73 | 73 | Log_File_Name : BS_Path.Bounded_String := |
74 | To_Bounded_String ("none"); | |
74 | BS_Path.To_Bounded_String ("none"); | |
75 | 75 | -- File name of log file. |
76 | 76 | end record; |
77 | 77 |
124 | 124 | -- called by Logger instances when detaching Facilities or when the logger |
125 | 125 | -- object gets out of scope. |
126 | 126 | |
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 | ||
132 | 127 | Invalid_Timestamp_Format : exception; |
133 | 128 | |
134 | 129 | 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. | |
135 | 134 | |
136 | 135 | type Instance is abstract tagged limited record |
137 | 136 | Name : Unbounded_String |
125 | 125 | end loop; |
126 | 126 | end Find_Closest_Match; |
127 | 127 | |
128 | return No_Element; | |
128 | -- Try all-wildcard as last option. | |
129 | ||
130 | return Map.Find (Key => (1 => Wildcard)); | |
129 | 131 | end Lookup; |
130 | 132 | |
131 | 133 | end Alog.Maps; |
71 | 71 | |
72 | 72 | private |
73 | 73 | |
74 | use type Alog.Log_Request.Instance; | |
75 | ||
76 | 74 | package List_Of_Log_Requests_Package is |
77 | 75 | new Ada.Containers.Doubly_Linked_Lists |
78 | (Element_Type => Log_Request.Instance); | |
76 | (Element_Type => Log_Request.Instance, | |
77 | "=" => Log_Request."="); | |
79 | 78 | |
80 | 79 | package LOLRP renames List_Of_Log_Requests_Package; |
81 | 80 |
104 | 104 | procedure Timestamp_Format_Setter |
105 | 105 | is |
106 | 106 | use Ada.Calendar; |
107 | use Ada.Calendar.Time_Zones; | |
108 | 107 | |
109 | 108 | F : File_Descriptor.Instance; |
110 | 109 |
176 | 176 | Assert (Condition => Position = Maps.No_Element, |
177 | 177 | Message => "No_Element expected"); |
178 | 178 | 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; | |
179 | 193 | end Wildcard_Lookup; |
180 | 194 | |
181 | 195 | end Maps_Tests; |
326 | 326 | ------------------------------------------------------------------------- |
327 | 327 | |
328 | 328 | procedure Iterate_Facilities_Exceptions is |
329 | use Ada.Exceptions; | |
330 | ||
331 | 329 | Log : Tasked_Logger.Instance (Init => False); |
332 | 330 | Facility1 : constant Facilities.Handle := |
333 | 331 | new Facilities.File_Descriptor.Instance; |