pax_global_header00006660000000000000000000000064124176760200014517gustar00rootroot0000000000000052 comment=49d9d7a665717c3e9319afe95c21a65fa533acb1 libalog-0.5.0/000077500000000000000000000000001241767602000131325ustar00rootroot00000000000000libalog-0.5.0/AUTHORS000066400000000000000000000001101241767602000141720ustar00rootroot00000000000000Reto Buerki Adrian-Ken Rueegsegger libalog-0.5.0/CHANGELOG000066400000000000000000000026021241767602000143440ustar00rootroot00000000000000Alog Changelog ============== Version 0.5 ----------- .Additions and changes - Drop PostgreSQL, SMTP and XMPP facilities - Simplify build logic and switch to gprbuild - Remove Alog.Version package .Bug fixes - Make policy database safe for concurrent access Version 0.4.1 ------------- .Additions and changes - Minor corrections to README. - Drop major version symlink. - Add revision number to library version. Version 0.4 ----------- .Additions and changes - Use latest libaws jabber API. - Remove policy handling from loggers. - Change default loglevel to Info. - Rewrite tasked logger exception handling. - Cleanup of syslog facility. - Auto-generate documentation. Version 0.3 ----------- .Additions and changes - Architecture cleanup. - Tasked and Active loggers. - Loglevel policies (source and destination filtering). - Coverage report generation. - Profiling support. - Provide code examples. .Bug fixes - Make stdout redirection work with FD facility. Version 0.2 ----------- .Additions and changes - PostgreSQL-based facility implemented. - Introduce two build types: base and full. - Transformations infrastructure implemented. .Bug fixes - Compile-fixes for GNAT 4.3. Version 0.1 ----------- .Additions and changes - File_Descriptor facility implemented. - Syslog facility implemented. - SMTP facility implemented. - XMPP facility implemented. - Basic logger support. .Bug fixes - none. libalog-0.5.0/LICENSE000066400000000000000000000634711241767602000141520ustar00rootroot00000000000000 GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Libraries If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker. , 1 April 1990 Ty Coon, President of Vice That's all there is to it! libalog-0.5.0/Makefile000066400000000000000000000063421241767602000145770ustar00rootroot00000000000000# # Copyright (c) 2008-2014, # Reto Buerki, Adrian-Ken Rueegsegger # # This file is part of Alog. # # Alog is free software; you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as published # by the Free Software Foundation; either version 2.1 of the License, or # (at your option) any later version. # # Alog is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with Alog; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, # MA 02110-1301 USA # PREFIX ?= $(HOME)/libraries INSTALL = install MAJOR = 0 MINOR = 5 REVISION = 0 VERSION = $(MAJOR).$(MINOR).$(REVISION) ALOG = libalog-$(VERSION) TARBALL = $(ALOG).tar.bz2 SO_LIBRARY = libalog.so.$(VERSION) A_LIBRARY = libalog.a LIBRARY_KIND = dynamic SOURCEDIR = src OBJECTDIR = obj LIBDIR = lib COVDIR = cov ALI_FILES = lib/$(LIBRARY_KIND)/*.ali GPR_FILE = gnat/alog.gpr PWD = `pwd` NUM_CPUS ?= 1 GMAKE_OPTS = -p -R -j$(NUM_CPUS) CFLAGS ?= -W -Wall -Werror -O3 all: build_lib tests: build_tests @$(OBJECTDIR)/test_runner build_lib: @gprbuild $(GMAKE_OPTS) -Palog -XALOG_VERSION="$(VERSION)" \ -XLIBRARY_KIND="$(LIBRARY_KIND)" -XCFLAGS="$(CFLAGS)" \ -XLDFLAGS="$(LDFLAGS)" -cargs $(ADAFLAGS) build_tests: @gprbuild $(GMAKE_OPTS) -Palog_tests -XALOG_BUILD="tests" build_all: build_lib build_tests clean: @rm -f $(TARBALL) @rm -rf $(OBJECTDIR) @rm -rf $(LIBDIR) @rm -rf $(COVDIR) $(MAKE) -C doc clean dist: @echo "Creating release tarball $(TARBALL) ... " @git archive --format=tar HEAD --prefix $(ALOG)/ | bzip2 > $(TARBALL) install: install_lib install_$(LIBRARY_KIND) install_lib: build_lib @mkdir -p $(PREFIX)/include/alog @mkdir -p $(PREFIX)/lib/alog @mkdir -p $(PREFIX)/lib/gnat $(INSTALL) -m 644 $(SOURCEDIR)/*.ad[bs] $(PREFIX)/include/alog $(INSTALL) -m 444 $(ALI_FILES) $(PREFIX)/lib/alog $(INSTALL) -m 644 $(GPR_FILE) $(PREFIX)/lib/gnat install_static: $(INSTALL) -m 444 $(LIBDIR)/$(LIBRARY_KIND)/$(A_LIBRARY) $(PREFIX)/lib install_dynamic: $(INSTALL) -m 444 $(LIBDIR)/$(LIBRARY_KIND)/$(SO_LIBRARY) $(PREFIX)/lib @cd $(PREFIX)/lib && ln -sf $(SO_LIBRARY) libalog.so install_tests: build_tests $(INSTALL) -v -d $(PREFIX)/tests $(INSTALL) -m 755 $(OBJECTDIR)/test_runner $(PREFIX)/tests/ @cp -vr data $(PREFIX)/tests cov: @mkdir -p $(COVDIR) @rm -f $(OBJECTDIR)/cov/*.gcda @gprbuild $(GMAKE_OPTS) -Palog_tests -XALOG_BUILD="coverage" @$(OBJECTDIR)/cov/test_runner || true @lcov -c -d $(OBJECTDIR)/cov/ -o $(OBJECTDIR)/cov/alog_tmp.info @lcov -e $(OBJECTDIR)/cov/alog_tmp.info "$(PWD)/src/*.adb" \ -o $(OBJECTDIR)/cov/alog.info @genhtml --no-branch-coverage $(OBJECTDIR)/cov/alog.info -o $(COVDIR) prof: @rm -f $(OBJECTDIR)/callgrind.* gprbuild $(GMAKE_OPTS) -Palog_tests -XALOG_BUILD="profiling" valgrind -q --tool=callgrind \ --callgrind-out-file=$(OBJECTDIR)/callgrind.out.%p $(OBJECTDIR)/profiler callgrind_annotate $(OBJECTDIR)/callgrind.* > $(OBJECTDIR)/profile.txt doc: $(MAKE) -C doc .PHONY: cov doc libalog-0.5.0/README000066400000000000000000000037431241767602000140210ustar00rootroot00000000000000Alog README =========== Alog is a stackable logging framework for Ada. It aims to be straight forward to use and is easily extendable. It provides support for various logger types, log facilities, loglevel policies and message transformations. Prerequisites ------------- Alog is written in Ada so you need to have an Ada Compiler such as GNAT installed to build Alog. The library includes facilities to log to files and syslog. Download -------- Release version ~~~~~~~~~~~~~~~ The current release version of alog is available at http://www.codelabs.ch/download/. Verify a Release ~~~~~~~~~~~~~~~~ To verify the integrity and authenticity of the distribution tarball, import the key http://www.codelabs.ch/keys/0xBB793815pub.asc and type the following command: $ gpg --verify libalog-{version}.tar.bz2.sig The key fingerprint of the public key ('0xBB793815') is: Key fingerprint = A2FB FF56 83FB 67D8 017B C50C F8C5 F8B5 BB79 3815 Development version ~~~~~~~~~~~~~~~~~~~ The current development version of alog is available through its git repository: $ git clone http://git.codelabs.ch/git/alog.git A browsable version of the repository is also available here: http://git.codelabs.ch/?p=alog.git Installation ------------ The Alog library has no special dependencies. To run the testcases, you need to have the Ahven Unit Test-Framework installed: * Ahven (Test-Framework): http://ahven.stronglytyped.org/ The building and installation process of Alog is simple. Just type in the following commands. You must be root to install the library system wide. $ tar -xzf libalog-{version}.tar.bz2 $ cd libalog-{version} $ make $ make PREFIX=/usr/local install This will compile and install the Alog library. If no `PREFIX` is specified, `$(HOME)/libraries` is used as installation directory. Tests ----- After compiling and linking Alog, you can test if everything works as expected by typing the following command: $ make tests You should then see `PASS` behind each of the tests. libalog-0.5.0/alog.gpr000066400000000000000000000030551241767602000145710ustar00rootroot00000000000000-- -- Copyright (c) 2009-2014, -- Reto Buerki, Adrian-Ken Rueegsegger -- -- This file is part of Alog. -- -- Alog is free software; you can redistribute it and/or modify -- it under the terms of the GNU Lesser General Public License as published -- by the Free Software Foundation; either version 2.1 of the License, or -- (at your option) any later version. -- -- Alog is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public License -- along with Alog; if not, write to the Free Software -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, -- MA 02110-1301 USA -- with "alog_common"; project Alog is for Languages use Alog_Common.Languages; for Source_Dirs use ("src"); for Object_Dir use "obj/lib/" & Alog_Common.Libtype; for Library_Name use "alog"; for Library_Dir use "lib/" & Alog_Common.Libtype; for Library_Kind use Alog_Common.Libtype; for Library_Version use "libalog.so." & Alog_Common.Version; for Library_Options use External_As_List ("LDFLAGS", " "); package Compiler is for Default_Switches ("C") use External_As_List ("CFLAGS", " "); for Default_Switches ("ada") use Alog_Common.Compiler_Switches & "-gnatwe"; end Compiler; package Builder is for Default_Switches ("ada") use Alog_Common.Builder_Switches; end Builder; end Alog; libalog-0.5.0/alog_common.gpr000066400000000000000000000026221241767602000161400ustar00rootroot00000000000000-- -- Copyright (c) 2009-2014, -- Reto Buerki, Adrian-Ken Rueegsegger -- -- This file is part of Alog. -- -- Alog is free software; you can redistribute it and/or modify -- it under the terms of the GNU Lesser General Public License as published -- by the Free Software Foundation; either version 2.1 of the License, or -- (at your option) any later version. -- -- Alog is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public License -- along with Alog; if not, write to the Free Software -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, -- MA 02110-1301 USA -- project Alog_Common is for Source_Dirs use (); Version := external ("ALOG_VERSION", "0.1"); type Lib_Type is ("static", "dynamic"); Libtype : Lib_Type := external ("LIBRARY_KIND", "static"); Languages := ("Ada", "C"); Compiler_Switches := ("-gnatygAdISuxo", "-gnatVa", "-gnat05", "-gnatwal", "-gnatf", "-fstack-check", "-gnato"); Builder_Switches := ("-g"); Binder_Switches := ("-E"); end Alog_Common; libalog-0.5.0/alog_tests.gpr000066400000000000000000000041261241767602000160130ustar00rootroot00000000000000-- -- Copyright (c) 2009-2014, -- Reto Buerki, Adrian-Ken Rueegsegger -- -- This file is part of Alog. -- -- Alog is free software; you can redistribute it and/or modify -- it under the terms of the GNU Lesser General Public License as published -- by the Free Software Foundation; either version 2.1 of the License, or -- (at your option) any later version. -- -- Alog is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public License -- along with Alog; if not, write to the Free Software -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, -- MA 02110-1301 USA -- with "ahven"; with "alog_common"; project Alog_Tests is type Build_Type is ("tests", "coverage", "profiling"); Build : Build_Type := external ("ALOG_BUILD", "tests"); for Languages use Alog_Common.Languages; for Source_Dirs use ("src", "tests"); Compiler_Switches := Alog_Common.Compiler_Switches; Linker_Switches := (); case Build is when "tests" => for Main use ("test_runner.adb"); for Object_Dir use "obj"; when "coverage" => for Main use ("test_runner.adb"); for Object_Dir use "obj/cov"; Compiler_Switches := Compiler_Switches & ("-ftest-coverage", "-fprofile-arcs"); Linker_Switches := Linker_Switches & ("-fprofile-generate"); when "profiling" => for Main use ("profiler.adb"); for Object_Dir use "obj"; end case; package Compiler is for Default_Switches ("ada") use Compiler_Switches; end Compiler; package Linker is for Default_Switches ("ada") use Linker_Switches; end Linker; package Builder is for Default_Switches ("ada") use Alog_Common.Builder_Switches; end Builder; package Binder is for Default_Switches ("ada") use Alog_Common.Binder_Switches; end Binder; end Alog_Tests; libalog-0.5.0/data/000077500000000000000000000000001241767602000140435ustar00rootroot00000000000000libalog-0.5.0/data/Dst_Loglevel_Fd.ref000066400000000000000000000000231241767602000175300ustar00rootroot00000000000000[WARN] Testmessage libalog-0.5.0/data/Log_Append_Fd.ref000066400000000000000000000000241241767602000171560ustar00rootroot00000000000000Facility1 Facility2 libalog-0.5.0/data/Log_FD_Facility_Lowercase.ref000066400000000000000000000000721241767602000214620ustar00rootroot00000000000000logger test message, fd facility with lowercase transform libalog-0.5.0/data/Log_Multiple_FD_Facilities.ref000066400000000000000000000001361241767602000216420ustar00rootroot00000000000000[DEBU] Logger testmessage, multiple facilities [INFO] Logger testmessage, multiple facilities libalog-0.5.0/data/Log_One_FD_Facility.ref000066400000000000000000000000441241767602000202560ustar00rootroot00000000000000Logger testmessage, one fd facility libalog-0.5.0/data/Log_Overwrite_Fd.ref000066400000000000000000000000121241767602000177320ustar00rootroot00000000000000Facility2 libalog-0.5.0/data/Log_Source_Loglevel.ref000066400000000000000000000001511241767602000204300ustar00rootroot00000000000000[INFO] Test: Source test (logged) [DEBU] Default source (logged) [NOTI] Unknown: Unknown source (logged) libalog-0.5.0/data/Logger_Loglevel.ref000066400000000000000000000000751241767602000176130ustar00rootroot00000000000000[DEBU] Debug message (logged) [NOTI] Notice message (logged) libalog-0.5.0/data/Loglevel_Config.ref000066400000000000000000000003621241767602000176000ustar00rootroot00000000000000# This is a comment (ignored) # Displaced comment (ignored) # Next line is whitespaces only (ignored) # Default loglevel Default = Info # Source-specific loglevels Foo.* = Debug Foo.Bar = Alert Foo.Foo = Notice libalog-0.5.0/data/Loglevel_Config_Invalid1.ref000066400000000000000000000000521241767602000213230ustar00rootroot00000000000000# Invalid loglevel Default = Unsupported libalog-0.5.0/data/Loglevel_Config_Invalid2.ref000066400000000000000000000000441241767602000213250ustar00rootroot00000000000000# Completely invalid config file = libalog-0.5.0/data/Loglevel_Config_Nodef.ref000066400000000000000000000000521241767602000207070ustar00rootroot00000000000000# Source-specific loglevels Foo.* = Debug libalog-0.5.0/data/Set_Threshold_Fd.ref000066400000000000000000000001211241767602000177130ustar00rootroot00000000000000[DEBU] this message should appear in log [INFO] this message should appear again libalog-0.5.0/data/Tasked_FD_Facility.ref000066400000000000000000000010341241767602000201470ustar00rootroot00000000000000logger tasked test message logger tasked test message logger tasked test message logger tasked test message logger tasked test message logger tasked test message logger tasked test message logger tasked test message logger tasked test message logger tasked test message logger tasked test message logger tasked test message logger tasked test message logger tasked test message logger tasked test message logger tasked test message logger tasked test message logger tasked test message logger tasked test message logger tasked test message libalog-0.5.0/data/Toggle_Write_Loglevel_Fd.ref000066400000000000000000000000431241767602000213730ustar00rootroot00000000000000This is a message without loglevel libalog-0.5.0/data/Toggle_Write_Source_Fd.ref000066400000000000000000000001401241767602000210600ustar00rootroot00000000000000[WARN] No source given [INFO] Test: Source 'Test' [INFO] Source 'Test', source writing disabled libalog-0.5.0/data/Toggle_Write_Timestamp_Fd.ref000066400000000000000000000000441241767602000215660ustar00rootroot00000000000000This is a message without timestamp libalog-0.5.0/data/Trim_Loglevels_Fd.ref000066400000000000000000000002301241767602000200740ustar00rootroot00000000000000[DEBU] Testmessage [INFO] Testmessage [NOTI] Testmessage [WARN] Testmessage [ERRO] Testmessage [CRIT] Testmessage [ALER] Testmessage [EMER] Testmessage libalog-0.5.0/data/Write_Message_Fd.ref000066400000000000000000000000331241767602000177040ustar00rootroot00000000000000This is a test log-message libalog-0.5.0/data/Write_Transformed_Message_Fd.ref000066400000000000000000000000331241767602000222500ustar00rootroot00000000000000this is a test log-message libalog-0.5.0/data/ref_file1000066400000000000000000000001231241767602000156160ustar00rootroot00000000000000This is a test file with multiple lines of text used for Assert_Files_Equal tests libalog-0.5.0/data/ref_file2000066400000000000000000000001231241767602000156170ustar00rootroot00000000000000This is a test file with multiple lines of text used for Assert_Files_Equal tests libalog-0.5.0/data/ref_file3000066400000000000000000000001231241767602000156200ustar00rootroot00000000000000This is test file3 with multiple lines of text used for Assert_Files_Equal tests libalog-0.5.0/data/ref_file4000066400000000000000000000000231241767602000156200ustar00rootroot00000000000000This is test file4 libalog-0.5.0/doc/000077500000000000000000000000001241767602000136775ustar00rootroot00000000000000libalog-0.5.0/doc/Makefile000066400000000000000000000014531241767602000153420ustar00rootroot00000000000000DESTDIR ?= html STYLEPATH ?= . ASCIIDOC_OPTS = \ --backend=xhtml11 \ --conf-file=page.conf \ -a stylesdir=$(STYLEPATH) \ -a linkcss \ -a disable-javascript \ -o - DST_HTML = \ $(DESTDIR)/index.html \ $(DESTDIR)/README.html \ $(DESTDIR)/CHANGELOG.html all: $(DESTDIR) $(DESTDIR)/asciidoc.css $(DESTDIR)/alog-arch.png $(DST_HTML) $(DESTDIR)/alog-arch.png: arch/alog-arch.png cp $< $@ $(DESTDIR)/asciidoc.css: asciidoc.css cp $< $@ $(DESTDIR)/index.html: index page.conf asciidoc $(ASCIIDOC_OPTS) $< > $@ $(DESTDIR)/README.html: ../README asciidoc $(ASCIIDOC_OPTS) $< > $@ $(DESTDIR)/CHANGELOG.html: ../CHANGELOG asciidoc $(ASCIIDOC_OPTS) $< > $@ $(DESTDIR): mkdir $@ clean: rm -f $(DESTDIR)/*.html rm -f $(DESTDIR)/*.css rm -f $(DESTDIR)/alog-arch.png distclean: rm -rf $(DESTDIR) libalog-0.5.0/doc/arch/000077500000000000000000000000001241767602000146145ustar00rootroot00000000000000libalog-0.5.0/doc/arch/alog-arch.graphml000066400000000000000000000341761241767602000200400ustar00rootroot00000000000000 Alog Framework Ident_Levels Policy_DB Default_Loglevel Logger Facility File Syslog ... Process Accept_Src Accept_Dst Write Log_Message libalog-0.5.0/doc/arch/alog-arch.png000066400000000000000000000472421241767602000171700ustar00rootroot00000000000000‰PNG  IHDRV? ÔGNiIDATxÚí \\å½þÇÝVMŒM5®U[­½mÿ·W½ui½µšÖîíÕÚko[ïÕÚ[µZc­±µj#! IH‚ bÄ a ¶a؇}˜aß·°3„ó‡œÌưdXfæù~žÏ|ÞyçÌÌ9ï{Þ÷yç=‹B „B\‹€B-B¡B!´@B!„H!„Ð !„Z !„B $„Bh„B-B¡B!´@B!„H!„Ð !„Z ™âôéÓL3Í4ÓLÏ1M $„âê1-еê’B-'gÓ¦M,¡Â~ŸEA-g$33óý÷ßÇëbôû›L¡G‡s®[—Äù˜œœôòòÊÎÎþàƒ^ dHBV"ÕÕÕü1¾¾¾H[í÷'&&Nž<¹s $ðVÎW*•Û·oG~FF†U«˜)3++k÷îÝò§]]]¡¡¡ø©mÛ¶…„„ ÉKæææÂ¤7oÞüá‡Ö××îÝ»×ÝÝýÀ’‹§¦¦b¨¨¨ññqdÂÑ;::¤Ñh4R9ÈŸu»ÌVO^É–––]»v©Õj'÷Z !®ËáÇa*Hài«Ö•œœØ?…¿¿JJŠœtfŠC‡Í˃ƒƒñ-9ç£>Òétƒatt4666::Z^kÕÓÓcKKKÛºu+¾(¿ýôÓO±ŒJ¥ èí퉈ˆˆGæ‰'àH`ñ­±±1¤srr?ëv™­ž´ UUU;v쨬¬t`ãéšì­œìÈZ3D5%º–¦¶z²3²¯úìp×Ä9ÎN±xvH $d…/A·ãA¯HÃH,­Ë8¢joo—)$¤8L °fr;˹@$úúúfZ+¸ "0yÉ) Û3{‹X ooo‘Ræàààž={€W………!ðÛ•ŸŸ4ràd³n—Ùêá-¼ñ_ss³£ºßP»ÐrZhˆ3hIZÓ…¶L¡=Ë…„íÅV·žPg›ÓFú[‡‡‡±¿a„„Ý v8ä\ óÀ¹@'!!ÁÌ¢cipÉ&%§”ŒGÊ—"^Q YÜ‘œ‡‡‡´ï¿ÿ¾Õ%­¾Åjo‚ô]tj’úøøTWW-„~EºYð[%|¬p!a{±Õa_’~-T|"Žô1gZ+1Ĉƒ'x!vD„Œ q~ÌÂ>€´Ú1 œK&~J£Ñ`HŽa8^ãÅY-pß¾}Æ[!ãïï_ZZúÉ'Ÿ WÄ…È1ûÓ™¢@³éïïß»w¯ÙI³ŽÁP³ ‹ê£m°pø ¢ù©7 Õ‡}”Д ´¥»°½ØêJ?AõšXðB]ä¤þx«¾¬©© {jûöû¥²),,¼Äë)—ÏÜ-sÎç qfrßï„‚.¯H/¡Ìç§rŒ?•÷ܾ¶2üORº-þ/ܸz‰×S.F„â`ŒuwwëtºÒÒÒœœœää䨨¨   ___•J%vœ]B‰&7sŽœþÌeŠK.uñEb&^—úÞÙçʇH!ŽAqq±ôÜàM3(öà+Þ¿|ƒB·uYA $„‡£¹¹ùÀVýî822".´â-ÐëWŠõ_Q”oRŒ}¨(~Oñ_÷;€r.Ðyà\ !M^^Þ–-[ŒýoëÖ­ò¬V¾žÝ¯ØûŒâžuŠ+.U|ýfEÔËŒ !„Ì:è‚‚OOϰ°0ÙÿÜÜÜ´Zíù…–ÏF´@Bq,ª««½½½ýýý[[[ûûûe 4{ "-pvem~Öö*-BV:ÍÍÍp>¸ ”ÓÛÛ+ù_DD„ùÒ´ÀY•½Q¼Gè©ÿá\ +¹@B…îîîððpOOOFcÜ;#„ÿ8pÀÊ#îŽÜ.$?+ÞS½‘ng]9ï¡_9÷<£@BY‰ŒŒŒ ƒ†ùaÌjés: X~q2îçBÔCBÔÃBÞ»t;+:p…õ!þÉÆ¨ßÓ !deÃËÈÈØ±cGll¬U“õõõÍÍÍV?:[æ+öòê7åzñÁñô<3Åÿ'B@!oSNÄfZ !„¬ 4——WHHHww·ÅlôÔÃ]“~«Å@Ço• Ù.®¥í×á/9oãu,ååXe4ç]β©««Û¿¿ŸŸ"¼ ù‰‰‰±‚ÝâSã5;§]± ¤OyÿˤØ3/ÒíĉÆÏ ìêêbHq|||šššdKððð»6äãS«ßÚ´i“Ybihmm Ú»woyyù…ÿ¶whhh8éBðÓ.¨\/Î ª7Šçˆº¦rþ&ä½#× Ež5Q”J%,Ðø©ñ»m<5žHqÒÓÓccc¥tcc#,MvDä›_H7³.6ýýýQQQ»wïÎÉɱWç D4Ó Noš8t«xDTý¦xv ¼Ðeã?ÄÄÑ9o2_/ˆxW9ö„ÄÄDì EEEz½¾§§gtttrr’Hqlz{{wîÜ)™ŠJ¥Ú¼y³ø…©)4ä÷õõÉV—••’^‘ ËËË3¶@9"´aÞÞÞ]]]Råž={¼V8öîÝÔÞÞ¾H DW·îîînll¬¨¨(((@_Ÿ––†á/úýd×%€rÀ°FƒQBKK vƒ±±1{‹¦B–™¡¡¡mÛ¶!úä“OðÖ××iä [zžm twwÿø¯ XNwàÀýû÷#±ØÛ.‚(¸`SSSMMMii)º{D„¹$7å€ÒÀpñüOŠï1n°×D -²ü Ø HLLD:!!é#GŽXõ<Û¸oß>ô’ ^ øPHHˆ——Wqqñ’m;ɱæˆ8ÂzµZmÍծдùp>”ˆÿ0*2 ¶ýsÎ牋PTT3C—‡4^‘F04 ܱcÇùÇï ‚Z­ DØIXXØW```@©Tâ×T*••›y.¾ âOßÀûûû{zzººº:]%( ” JftttVÿcHq<ÆÆÆ¶mÛ†W)íááaæC3Y  Ÿšííí½yófŸÊÊÊYÿ„±&Ìѧ}OøœÒ¼ V!úz¬É°Ë32Je‚’Á@ÁîþG $„¸(òSm#""lßäl)œ%¦HŲHeN $„¸ÆOµei8œ tݺ$„ÌŠåSm‰+C $„¸3=Õ–Ð !Äi±ýT[B $„'d.Oµ%Îç]·. !ÆÌñ©¶„Q !„8özª-¡BˆÃ`ß§ÚZ !„8‹ñT[âpp.Ðuë’×dñžjKBÈ e±ŸjKh„²Y‚§ÚZ !„¬,–ò©¶Ä±à\ ëÖ%!Nϲ<Õ–0 $É$1‚UïМ9sFzªmffæøø¸W=›êRÖ-л¿‘®ÉÞÊÉŽ\¡5CTS¢kij«';ó'{«ÎwM±ØÏ[U߭ƶ;_ÕÇ…û&D|2RwröªïÈÅþv¸Ó¡ª~’ÍvºÙöU7ÛÅ~d -йzÀ¡v¡å´Ð+ {UKªÐš.´e íY.$l/¶ºõ´Ð˜€r8Ûœ6Ò×"=„Zz5Ú•ó¹ ÌOìDXõFU?Ùœ2ÚÛ¸ò«žÍÖz³íoEÝ¡âÆÆÆæ^wœ tæ[—“ýZA-ÔÇM§…’½BâÓBèW„ ›¿UÂÇ ¶[ö5!é×BÅ'b‡¢9ÓRÖÓÓÓ××788ˆFe0œéêéÉ3õØFV½µªl-^ÉUÏfk«Ù¶V.vÝÑ…¡A!ÔG Ú`áðÄV¤Þ(TôQBS‚ЖîBÂöb«+ýÕkbQ Qé"'õÇ[u%íííhQ]¢99I,8Ò%è#YõÖ«Å¢?Þ®+”«~hhHšJ\Ͷ™Ív–f«/kjjêèèèïï_ŒfK tŽ(`BlEuaBM8˜Êw§àmm¨K %ÐxJlQk…ºcÃ5QeeeµµµÍÍÍZ: 6ƳêmWýxí±²Òb­V‹Î´»»U¿"\ÍVœu·¼Í–èÇÁtBÍa¡)^\'h¶ ºcâ[Jz4' *âËó“ «ªªÐ" qôá“C­¬ú¹T}uAbAAAee%ÂÁÞÞ^TýÄÄÄr­cÝÍ¥îÊò¦›-\ÍvttÔF³å\ Kζ¦ Õþâ(2ò›âœP•?e¢ú“â¡•òý ùÇ233Ñœ´··:ü3Ä;rYõs©úÖ£pÁššš¶¶¶å[RYws©;}^„Ül;::ìÛliNAÝ1A{Tˆù® Ù&T ÌUù©8¢Lúu_qHrrrVVVii)¢Œ(ÇÆÆúXè¤^)V}ô#¬zÛU?Xœ””¤R©JJJÚ&–‚ÚpÖÝìu—üÛh¶jµº¬¬L:~cÇfK t *>Ï(ó_#èÂ0h¢¬¨ÂWûÚXMDBBBzzºF£ÑétÝÝÝ,´æ0«~.U?YŽªOKKC XWW×ÕÕµüUucÝͳÙêõz4[ _hĈRoñŠ¢â+Ò”¥´ÁBÐÍgk#ãââNŸ>ŸŸ¯Õj;;;‡‡‡Û1úYÙU¯P(VBÕ uRÕçååÕÔÔttt -ótà n¶Ë_kFu7¦ŠOMME³­­­µ=|á\ ³ÍbÜZ]]=Ë¢Å{„z¥Ø–ðŠ´ý$¶»þà²IwL<éN'Z`JJJnn.úÁnjµº¼¼|–Õ[̪7fÁ{Žeb©÷+ÓªÏÉÉAƒjoo_T LNNÆk¹š-Ôšìö»ŸÞ¿ní5W\~é#÷Þ³ï‡løFu' _ì>r¥®tš››ÝÜܼ¼¼T*­õ…ŠvŠEˆm)ZLÛObK°ë.›Î•Y`ÿÖ­[===Ñøg|ÞŠ¯z«¿³¤û•QÕÙ`UUU‹mõõõ›6mòööÆ8fƧø.ZÝAß{èî7žýN[ò{£¹ÛN|éGÜã ñ›--ÐP*•›¦pwwŠŠ‚)š/Q¸M¼ªû ^‘¶ŸÄ–`‘9š½ùµÿþÖ Ÿ»Bo¥ÌùÀu«?‹Ìí¯ýPþ¢Õü³ù[7¿ü½ÛoZ³fÕgžûù}ƒª÷å¿ÛýÆo¹aõE]dß ‘ËÇ,dddHUaÐÑ£G­<hi«¾*ê§ÿjsÕUWüçc_íLy™†¼-ïþá±ÛÖ]{í5WzþåGf_·šY{íUÒ@ã¹îŸ_sU{Ò?¯ê—ÌADD„ÜlÑ„[[[—¬î «>sù@æûÆ9=©ïÍTÚ§>~áßî¹éÊË/ýÂ×~òÞ“fµ?¯öîpÍ–è`¹cÇŽMFøúúj4šóg绉G °¯àiûIܳ-2ß}áÑõ|±1ö¯Ðwï¿ã½?<ŠÌw^øÎ¿uWsÜ›Ð÷ü’üE«ù»^ÿÁãß¼³.úõž”¿ÿöGÿú—ß>,ÿÝϽKÚw+ŒËDZ,ë†H¸ê}||Љ-KÕÿ¿»nHþø¹aÕ»}©o¿ò_¼ð‹ûéþòãÞw‡öøÔæ†ÿ~Èìë– ã4~dËŸÖKéøŸýñ·ï^Ôª_J Dàîááa\w(--]‚f ýǽ·¿ú̃5QŒ3g*í×^¾ã™Ñ¬÷êO¼ñû_ÜkVYójïËÞl9èls›,€/&$$ôöö ¹ï‰·TÀ¾‚W¤í'q϶ȼóæ5eG_’Ò%!/~ñ–5RfEØËR&>•¿h5ÿžÛ×V†ÿIÊl‹ã 7®–ÿNýš}7aZçÊDZ,ÔÕÕYVýÖ­[cccŧ¥/fÕ›ÌZ,Ðú­[®_…Ä—n½»ÁL{ŽeÂ8]õêmëVg½ƒô‹Oݼå©E­ú¥´@i6ײî<==O:Õßß¿xu'5+”çÍŸ¿fõÕWü÷¾ÖûºÒ¾õ†U{ÿúƒå« ^íÝášíJ±@ÿMdžœ?8†½$ó•ó¯ö“¸g[d^y™bÄ{:ÞJ™£žÏ”¿h5ÿ3—).¹XÔʼn9x•ÿnrÿâÜ„÷\ù`$îµäÈñ<©¥­úÜ·Ý£XóÙi_D ší–_·L˜¥y¯âÈ b½ùŰ·óW½»»{xxxccãâÕ±Ú=Y¯øÎݶJ;ÿŠ_|Cñ¹«w]¯ˆ}Õ¼‚æÕÞ©îœß±g0ì› ƒÁàååe649EbiûÁ;×*Ê6M§Kþ©øâç§3+ÞŸÎħò­æ£ùé¶Îõï¥--ÒP___ãª÷ðð@èßÝݽ,UºxNѽ[1ñ‘ø*-ƒ~»Á¼,ð¢‹Î§ÕSP\uÅì¥ _T¾¢X·Ê¼²æÕÞi´@ûƒv+·"„ËVN”_Ú~ð?R¬ÿŠ¢ÑCb‚w~4ùï)š·‹zâ«ç¿h5ßëWâ/”oRŒ}¨(~Oñ_÷Ó­“——g<\PP`~k¨¥­zô‘/‰ÃÿÚ-Чî^fË/Þ-æôìQlx|NøùkÄÚ—ß~ûKb˜’ôºSY þN®»   ÊÊÊ%k¶Ð¿®8ý†ŸuîR¼õ„â?î²UÚÏü»hchŒ°À›®5¯¬yµ÷eo¶Ž:H œ©.1Þwww??÷c•ÅìM&„Î÷xõ»ŠV‰BB:H‚×ÿ{D£¸gâŠK_¿Yõ2-Ð è£ó¡ö#""ÄãfK^õ–™'^#xTâm׉5(-3î£xû‡Š[Öˆµ¼ûé9Yà®§×~ö|v|ýì~ç±@ü¾››ªŠÝl‰ë‚™=r—ؾ0ÚÀ`¥~Ûù,K;ø±Z¯¼Lño·*’ÿb^YójïŒiv&!!Áä À%oK PÑ»Š;ÖÎ#)䀘–––‘‘1ãÅ +²ê¦~£ØøÄRTý’Y ¬ˆàg¹›ó2ÕÝK{Û5-̉•Ñnx\ѺS¡ßªxüÅëëgÏ_Rem~v2õwFè,ø]íèØç¥¸ûEÓöÅ­záôóKFè l¶v,í¥h×SugH{Õù-pÖ¸‹á‘øÍüü|㔯Cšñ'—®„~ÐëWâ–ë¯QüáÅоÙó—TÙÅ› žúŸ9¶%ygûöíÁÁÁâ•'+“#·;´JçøëE¯úÉ„§hö-í¥h×ól¶‚_¸Hèëëk|ÇqéÚ Gœ'ô!ùYñfzêŽ{4lq•óŽú•¡¸ßÍÝå ¹ÄÄD??¿•Ù.&#`ÕÏ¥êGbµâ,ÃÖÝêîLÜóŒ­[ öà“'Oîœ i‡Æ«R©Äà™Òý¥lüf|||QQ‘ô¶ººZºÙtç29™ššêåååáá5>>.å×ÕÕíß¿ßÝÝ}Ïž=Ri™ÓÕÕŠuضm[HHˆ8£¾¾¾´P­Uþ½3øÑј‰§\»êprôôŸºOo£Ù677£ÙŽÏTw|^  mmm^^^ºns¯Kì Ø'Z[[á¾ùùùí¢#NHHˆ;ÇIF*”’J¥BX[[‹xkppp–[X­xäªÇîTSSSPP€Á2úzl,:ŽåªzŒìþ›ÇŽ“®*9|øðªe’™™‰¥„@%†ª_^ ”êîÌ™335Û“®Y³E(7[;Áv˜(p^ à°‹c  ŒZ!,ƺ¡-aŸÁˆ#ÜŠŠ t…ØiÒÒÒP°Ø’]”Êý ‚øº›––TÆàŽ}w4ÓªG\‹ø½<¢Olì2V=,p‘~9""ÂÓÓAvddä|«%SUU…0A3ª~™¯‹7ª»îîn6Û¹7[„ïvl¶ÎyPÉÎ;£££¥Ë-\¹\[j¹nvQ ¡9¡+ÄP·´´û †–¹$7å€Ò(++ÓjµR'ˆ®ÐòÆö­z¸ 6 ¸ìUöµ¨¿ÿÛ¾}ûþýûÑEκp^^ÌO®z”Òðð𲇀l¶so¶åååˆÿà‹Ñly›lç##©9aGiooG‹ÒëõØujÎQí’HÛŽrÐét(“ŽŽ $WN'hǪÇFaÓ°rÕ£Ó_–ªGs^ì¿@Ì„Aä¶mÛ>\TTä¸UoÖlbm—«âœ ÙòyÎã9I·¤A‹êïïÇ€WÎärÕct¼BªÍyiþ#"Â;vÄÆÆ¶µµÙ®úÁÁÁ•YõR³E|Ãf»ôÍ–èl`‘zC -±Ó ] »<#S 4P&hE('ó¿•Võ‰‰‰KùwÍÍÍaaa;wîT«Õð9G¬zi^kÈf»ÄuG tZ#”:DbŒT,®Põ.XûŸ~ú©OUU•ƒV=›íÒ7[ç<#”âšÍ¹ºº.èïïÐÁ}Ïa,pX@œ†å=¨ƒ¸¡  ÀÓÓ3""¢»»›ÕAB\Å% za\\ÜÈÈ+…¬h ä\ !´@»300 T*wìØ¡R©ýN@„H¡Λîîî///FÃÚqnx] ëÖ%!lÎ6¨¯¯?pàÀÜoANÒ !N5z+//ß»woPPPkk+kŠÐ !®ÅÙ³gsrr<==£¢¢X ´@ !®ÕœGFF’““=<<ðÊSF]vßãuìG±3tPQ bAD„ˆ ýÉY„Q !„8oZ[[ƒ‚‚öîÝ[^^ÎꣲÍB\®9ëtºýû÷8p ¾¾ž•H d›!„¸\sÖh4^^^!!!¼¹š#Âë]·. as¶ ƒA¥RíØ±C©Tò”QFl3„—½ŒŒÄÅÅyzzbs–òæj“ÄZ !„,ÝÝÝ0‚‚‚Å>;œ‹ òº@ö#„ð Î¢°Ïãì× úh¡>Fh:-”ìŸB¿"Ý,ø­>V¸°½Øê°¯ I¿*>Çú˜3­•===}}}ƒƒƒðBƒÁ`÷@œQ !„8Wìü<Þ¡fA!ÔG Ú`áðDóSoª ú(¡)AhKw!a{±Õ•~‚ê5±(à…ºÈIýñV}YSSSGGG?‚B¸ }ˆr.ÂæF¨ò§LTR<"Z¾_Ÿ‘™™ Ôjµƒƒƒv¼F…HáèíB™éy¼\й9rÄJàR.h ÑšmBÅÊ\•ŸŠ`òo»‹Ž&''«Õê²2q^ †ö:J $„û`ù<ÞÞÞÞMSœ:uÊbéý≠þk]˜˜¦,Uá+„}m¬&"!!!==q¶^¯GØ=::êlȃ~„0 tÌžÇ+[ (..6Y´Ô[¼ðc…øŠ4e)m°tó˜6*>>>555??¿¶¶¶««kddd¦é@^È~„ÔYfäçñ&%%ÉèîînrAañ¡^)Z ^‘¦,¥;&ž+«‹Œ‹‹C˜——§Õj;;;‡‡‡íu £@B-pQ(++ƒ n2Ñáùûní¯-0ZLS–:W>°À”””ÜÜÜššç´@¶BhNCxxø&køúúNŸÐX¸M¼]<^‘¦,u®|h„Z cP\\¼uëÖM3!.—ï&èCW¤)K+Ÿ¹[ ¯ txp˜Ð—öööºº:F“‘‘‘çó÷÷÷ööÞ±cr„Ü÷Ä;¡ ‹Ç+Ò”¥Î•£@BGoÎ:÷ÌWοR–:W>´@B¡ÒkxF(!„Q -Ð>³¦Èy] ûBxP‡è¢È(B ¤ò@¨CY Û !´@Z e¢¬ ÂÁÏÒ^¥Bh´@SöFñ¡§þ‡×º"<8LhÎ̑ۅägÅ{`ª7Òí¬+ç!ô+gâžgHáèÍ©˜Œû¹õõ°÷.ÝΊ\!dýEˆ²1ê÷´@Bq*Ζùн¼úMA¹^|p<=ÏLñÿ‰PÈÛ”±™g„B:Ã]“~«Å@Ço• Ù.®¥í×á/9oãu,ååXe4¯ d?BˆÃÀƒ:s²À‰‰±‚ÝâSã5;§]± ¤OyÿˤØ3/ÒíĉÆÏ ìêêbH¡:¼ 'ýQ¾sÚ•ëÅyAõFñQ×TÎß„¼wÄ¡@à:¡È³&jƒR©„?5¾»»ÛÆSãÕÙfqn Ü;Ųw&ÒãŠÜÜÜvíÚÖÚÚº\],ÑL'8½iâЭâQõ›âÙ1ðB—ÿG?"ä¼mÈ|½ â]å±±±‰‰‰EEEz½¾§§gtttrr’Hq lhh𞢱±qÙ-¯ˆ!L¤§§{xx´´´,Kׄu@W޽¾¾¾¬0S«ü{gð££1?¯”pÕ(pôôŸ:•χ¿qRyb øBÀ”””ìììòòòæææþþþñññ™,×:<8LœÆcbbÒ§@ÂØ’““÷ìÙR©T62Ñߥ¦¦zyy!3** = ô/ˆ vîܹ}ûvô•ªä Ob.ë†U –Òuuuû÷ïwwwÇ¿çççÏå×.l6äÌ™3ˆD«««ñX™¤¤¤„„„¸)Nº6R! 4àØÖÖÖvtt JuÍ(â£7tXp©þ)û¯´´4„A###èìld¢ èííEfDDÂ©Ó <3òŸÎ% ”ÁíØ±CJ{zz"ÎÀêõõõ?~|±»&X þ [„xÁqEEEAA¶%€mA¿ŸìÚ P¨ÕjFƒQâuTÍØØ˜½&i„E§´´%¥‘(++“Ò{÷îmoo7[Øj¦··wWW—”F€(Mê4H™H|ðÁ °@ƒÁàææ&¥wïÞ Ÿ^²®I ‡††à‚MMM555(+t÷ˆsIn.Ê¥q â?øŸ4¸Á^Ï%„,vs>|øpqq±”.**Â[)íîî2ûîL™ïŸž„WÉœä%‘À2¢“ Aœ †-Íèä‚èßáýu:V«­™¢ÚU‘6·ÒÀàCÄÃÃèhÛþÇë¶!ÄQ0¶ m³Œ'Õð™óŠ÷íÛ‡°ü— ÓÓÓa{fË  öôô\²TpAôìˆo`„ˆAáÊy;]‚c”Ê%3:::«ÿ1 $„¬, T©T‘‘‘ÆŸ?~<++K˜Ï\ Z­ D·811ƒ “þåСCÒ\ )))Òˆ갤íuƒëà/àˆùäë"ÂÃÃa¥ø Xà®]»æòkv<"ŠÿEˆ}=¶}Øå™¥2AÉ Êìîç !‹Úœ?úè#Ngü©^¯G¦äCIII»wïöððLq¦Lô}ÙÙÙÞÞÞ›7oöññ©¬¬ŒÎÅ’J¥R>˦‹g„J‡RçÁJÛÚÚäJJJnº»»ïß¿_^gÛ¿fw#g‰)R±,R™Ó !ÙœÙiKx] ëÖ%!´@Bh„ç½ÍÚil²€UCh„;£R©,ÏØiii,B \ÃFBÈbPZZêîî·“.ÔCs>{ö¬Z­öððÈÉÉaùk%¼.Ðyê’å†çéé¹iÓ¦½{÷jµZ$|||ðºuëÖ‘‘–aÈîžg&99ÙrîM©T²d-pv8HˆCÓßßov`yŸBh´@Bœ£GûŸŸŸË„,1¼.Ðuë’奮®ÎØKKKY&„Q -WÁÛÛ[ò?OOO;>ÔZ !d¥“““#Y`rr2KƒÐç ú⌌ŒlݺÕÍÍÍìÁ³„¬L+áuÎS—„¬”JåÑ£GY„Q »ûef’%§­­­¶¶vE­»²Ò-svdpäl{ÏDC»A×:U7(Ê$íðØó±ÿ O³Ø#´@Zàò30t¶®y¢²ÞÕ4NÔ5ô-}ëD}E9¿°«c‡¯m6T7ˆM ¶ÉÐÝ;"=\zø8¼.èÜðº@×­Ë®¾‰rªkšÈ, ŠÞ<¸%`ðŸÞò9CQN/ìêØá÷„ IÎ.ǰBohh9ÓÓÓÓ××788#4 ¼ZƒÐþÁÉ’ZCY¡°f|Û¡A˜_lÖhAÕxYÝ8Fĺ– ŠrzaWÇŸ[>“1ŠV/,¯EM][ccc{{;Œphhá cAB tМËõ†âÚñ‚êq „“rÇj EÚqŠrM¡-h Ñé£n~k‡KKË´ZmSSSww÷ðð0]¬, ä¡BOÿDaµí¹û¤Ž•Öð–¢\\ႈÑ4rò+ *++öööŽŒŒLLL°ëàü¯ t†º¬k™È¯Gðç>ˆp0¯rœ¢(¨ªÞ°íРºt\UД‘‘¬©©ikk` H: %µ†"­Á7j(¥`4§|œ¢(I¹ãÑ£G†sKû“’’T*UIIICCÁÑÑQžC8è  ©Wè ›”h ê²qŠ¢de—Žï *ÖŽ%$$¤¥¥!¬««ëêê¡Z 3 *«¬7¼ås¯HS‹'…BÁBp,Uo ,­‹‹;}út^^^MMMGGÇÐЧ9H \éu‰qkuuµí%Ó‹ÆÂñŠ45/)αúÚÏ}ûÑŸ­²½°YâÂÿú’K.]ûùûþ/ýŽæX]±Ï|öê{¿ùhPd+k*©O“.­3ÀSRRrrrРÚÛÛi„è477»¹¹yyy©T*4Z«Ë¤Ž•ëD Ä+ÒÔ¼‘Ñ)ÍÿýÜ_¿þoßšËÂvüë¤ÜÁ#ÑåxuóÕ×\ë{$Ëò¿Nft½ð§÷¿ü•{YY Ü4`ÉÉɰÀªª*Z ¡: J¥Rz›»»{TTLÑl”ü±²:±ãij^‚ÓÈéiW~æ*)uæ©_¿²æºë!$ðÖxaãoÊzö…·¯_w+<ìù—6­¾vmTR³ôQböàµk>™Ø4ë_CxÕý[þÔê§±éÝ—_~%+k’›-¬\ ä¡6Ù±cÇ&#|}}5Á`8•7ZR;ŽvŽW¤©y N#%Žj~æþúÕ}HzûÛÞ¾÷›ÇÖB߸ÿ;¿ûÃ?Œ–Ðs/oú×ûþ#0ª<2¹õ©ÿ~õ¿zéù—ß—>òðV>ðíÎúג𠫯ýœå§Ñi/¼²ùkßx˜•µÉMƒȹÀ•kÄv]l²¾˜ÐÛÛ›3Z¬Û9^‘¦æ%yÊíšU×=ðíùG”Kù7Þ|Ç'¡…RÚ78ÿ¦[î”–¿%ÿÂM·~ Èo"+ƪþÉ“xÛ=ÐÆ_¿Iï½ä’K-WLšô Ìbe-@rÓ ’šõï’0_Ê?v옥º¹¹=zT§Ó¡…O‘_©y c5ÿÒË®|ãƒ)Þ/lü-ã%%}ùß~ñÓçýÞú°ÿºîzãƒö9þõß/úìÕk-?Å/<öÔÖ[ïú6+k’›-0 tH ƒ———±ùyzz¤h‹a×®½ý÷ïæHéçßQ_ûù;f²À5× ÷w“oºýþßþ5ñëþfîýŸÿóîoüÔê§ñj»ô²Ï°²h„èr ÝÊæçïï_^^nvI/-p1,ð¡¼yû=ß}ykô…/çánœÉÿãgïÝv÷#t+~ͳáþÇ^–2oùâCˆÛžy-fÖ¿~Ó»ñüïÊ«ÖüïßÓ­F?½ý†[ÿ••E $œ t­ºìîîvwwߺukll,Ú­Õ%i‹ao|Ðqߣ¼jÕõÒ¡N«øæ¾î‡~ð×k®½ùÊÏ^ûØ/·I™O¾ŒœöÙþkpÑÅ—\½zÝ=÷=ùü?T–ŸÄ·|ñÁçÞÎdeÑ £@×"!!vllÌÆ2´À¨ïÿzÏßÛÀr Z Y\h+Mv5]wý—^ÞZÉ¢XvÅdŒ¼ã;–L $Ng{§X‚?šõÊýˆˆOOÏÍ›7ûùù¡-e9üm?-peY½è¢‹¿ÿÌ.«G5eXPK£“ªÑ-ƒ‡NÑ9èTØÐÐà=Eccã²[````||üàà •^¯?|øðRÖåրФ‘ˆÍe—GQÆJÈÝ<èÝC $Ne111éS aœöìYìè{öìñððP©TVsÀäädjjª——2£¢¢ÆÇÇ%«ËÈÈØ¹sçöíÛOœ8!µã«fZ™-[¶XN×aù¬¬¬Ý»wK_´ºvá£ÈAŸQ‰Ù´@Š:¯·÷ŸQfŽÅ{®§ç±@ì»p©þ)0Þ•ÓÒÒüýý{zzFFÄ£ÿVsL(  ··™ˆá$ÓBø`Žˆ_P*•»víÚ¶mÛ±cÇ$Û÷úúúl¯†](©ùçqÚÿŸNŒ¹ù °ï£¨m‡ãÔ£x =5¸ÏOI ä\ óXàáÇ‹‹‹¥tQQ‘ñÜ›»»»|ÿè™r¤Ì÷ϯ«dZò’H`™9Z ±" DPhù-««a—º¬hMÎØtp µpLrAÆ‚”‹ë@ÌPBî(šCzÑØÎƒùÞ~ÇŸÈGæ¶@ØŒ›››ÙÝ2‘9¯(pß¾}½½½–³w ‹Û²e‹å·/ ¬¨íì<׳ýРä‚¢‡³Gc³F§P”K)N5Ÿ=ŠQ »ÿ@šfÌ+°Úû`”dÒSãµZmggçðð0-8¤ªTªÈÈHãœãÇgeeÍk.P­V¢% À™ÂÂÂ$Ó:tè4ˆÆŒÒÂ;vìÀ’¶£R½^ CËÄÄD«QàâÍ»z†›;Ã[Üýûc2FbU#>ƒðBF”«iÓÁ"‡âÔ£QiC»ü Dÿ;õ¡_4fzzzaaa]]]ww7š¡Ù -Ð1øè£t:qì™R»uRRÒîÝ»=<<$_´Ì¦ÎÍÎÎöööÞ¼y³Oee¥`tF(–T*•ò ¦‹±`uuµŸŸ~ f*Mš-ou5ìBeÃXwßHs[OEµ^¥.Œ¬ØØðITohcÊåtôÔ™µì<˜»ÏO‰à‚ÿí8‘œœŒoiiicc#ZèØØ:zç‰ÉPG¬ËªÆñÞ3cíg´úMqUº*/áTš2öÔñ˜øÈè“’"¢b¡c¦ ‡"­)bZa:jªPIÇfPxlˆ…‚MuDVØ «:|ÔDAP¨-2U b¢YÁÖtä„¿‰”Ч3éð´üLu0ÈDfÓ'‡Lä+)P¹? ÆçSjáúÈ_ íŒ=p8!33!`MMM{{ûÀÀ€Á` ZàʵÀ¹ ì4tö 7¶tWÖ4ä–§gåŸJÉŒKLO9—¬<™d¦(ö¼¢e˜Öq3)Íe¡HY1¢"Ìm¢c²ŽŸ’nª0«Š:¯£ÆŠjª(bË:&êÈy%B‡¡ð&*ÈT‡,(éè M 0•?’øiHâÁàôÚÔêà”ä)ÿ£)A𿪪ªæææÞÞÞÑÑQNZàB,ÐòѵËoM†3Cg{úÇڻ뛻*µš’êì¼’LuaZfÞéôlc¥¤™(YVê´’lꔤÓç•h¬”ì Å'Ï ¤iř꤅bOÍ Äi0•2ÁD1²â§mKjè8w^QÆ:)*ÒTP¬-3Ó u¸©Â ¥úhLVptÖ‘ã”Ý­>ªÌŒ/Òjµð¿žžžááa†€„è<ˆ8<Ù78Ñ=å‚-=µú¶ŠšÆÒŠº¢ÒšÂâ*¨ ¸*¿¨RVž,Í´rÍTh®¨ÀDÙ²òE©-”•g"•¬Ü (s6e@9ç•n¬lQi¦J…Ô&:-+kZ)²TÖ•œi¢$S²Pb†‰$¥Ï ´ŠxSÅIJ­ˆ=]®L)I¦ì§” èÄ骓i5‰*}GGG__ýs´@g«KÉE€ ŽwôŒ´u4µõ""Ô5vÔ6´×ÖŸ—V–~Z5fÒµW›ª ª›Aµí•ªÐš¨\VM›¤2S•V›«ª:¯b ™JUš¨PRÅ´ ŒUn¦V(*;¯}ÿý÷‘ÅW|ãßP*• #fºŸŽÕ***^{í5üÔªU«ž|òÉÐÐÐ[o½™ò}pðöøñãH———/YXXˆOñ›òmk|}}ï¾ûîË/¿ü†nxóÍ7i{´@B tu 4~†ƒÔ,ªÕ,” Œ‡€±'½òÊ+?ü°t¹xÁuÞzë­‡zèÔ©S999?ûÙÏž{î9É™ðéúõë“’’àC¯¾úê½÷ÞkæFV±ºþâÁLHHP«Õ?ýéOÿ÷ÿ÷_þå_üüü¤[£dÇûP—ÍcOºâŠ+`fR |§AæÅç@^%’>•‘ÞšeJ”J,°ü •JuõÕWÃ’"‘™™‰X3//ÏrIÔ¦±úúú~ûÛß^µjÕ-·Ü²}ûvÚ-Ð]×-Ú.õèaW”ÍJéS2Æžtë­·FEEIéÈÈHé£Ûo¿=..®Øéð£ÙÛ‹.ºHÎ)²³ÌÄ_œ4G4 ¥pfàrÎôË_þrÕªUˆŸ6lØ }ßzë­·¨]~ùå_úÒ—`HÈA &™YÎø"ÞÂÒ`fW_}5ÒéSH3#6c¤Ìääd|ñ¶Ûn»ì²Ëî¼óÎ-[¶H‘ܺ)¿nuIc |ï½÷àšXÕ»îºkÏž=´=Z aèºQ ì|-ÝÓ2îЕ¯š;s@²(Ù¨$ÔFHq˜Læ9d©ç …Ð -8 åS(›Ÿ¥ØÀ"ù16 I:$8«'™Ù’]ÑŸ-Љu 46¿f¨k²_€À]T6É4ÅÌŒC%ÒLÇ<-OZ!´@¹@²Xu)[ d~’ØZ -Ð]" ”OR-Ði„èRØd$öƒ„H $´@°ÀzÃyóëœVZŸ¡C\‘Ô´LZ çh®4(Yà”ó5ž“:§€½!qA2³‹i„èbQ ‘ùIª¬ë`oH\¼²6Z ¡º”ŽËÎ×uL«¨¬Ž"q)ÔZ«þG $´@'·@có“Tß1QQÛ¡Î)༠qzÒU¹3Å´@Îѹ.ËêÇÍœoZíÓÒ«mBg"TµžW­±ZDiMU5›¨ZRÓ´ªÌÔh¨4UÔp^åõ†ý¸þ‹¢.PìR-Ð9‘-Жùµ™™ŸaÚüZg0?kΧÉùšçã|¦æ‡•/ѱƒ¦h„Hjfæça_ƒ¡T?^Ló£h„H.Ôï˜góüÌoÖ°Ç<)Z á\ ±ç\à¬Ç<ëæyÌÓ>aŸÅ1O†}-0 $vŽyÌ“¢h„èªhÕül†}µ‹ªK9Ou¡h„HÛWTØÇcž-p.,Q]–êÇ—Æüfû¤cžìp)Z aH–¸ÎJ8Õ…Ç<)Z ¡’e³@˰¯B×—W’‘™Åhg¾;ZfŽ*·¬ ²—Hh®hVOu)ªh:šÊþ‘¸ ©9Å ´@ÎÑ]n.Ðò˜gym¥ÿegg•””TÍ“Êå£bY)_rÊf ´´T£ÑäççgffÒël¸`~E7-Ð], ´˜ðËÎ+1îÐvttôÍ^{гPºíA×Bé´LûlèõúœœÚU2ÕZ ¡º–Zžê’ž1=ÿ—ššªÓéèC‹aE³Ò¶PZçzž•005Hh.gfçyÊ=BII‰‹ûÐb[Ѭ´,”æÙÈÊâ‰NV rþˆèZs–W8È! º`úТúÐ\hZ(6©¨¨ áÑ £@W-/ï“ÏYQVä”>dƒ{P?3z½ž†G $´@—¦D?nym»Ô:­X²Þèf&##ƒžG $´@×¶@‹»ºH}Aqq±ë„Ds·"__ßo¼Q¡PÌׇðÝü©[ø/ã·µ30—é@ü-çhÎY—°@Ë[šM÷EE®)¦¸ä’Kn¸á†ÿøÇ'Nœ°mE·Ýv[xxøÂlIöã´%–Ÿjç ~Á,§Æééé´@Z aèÂQ nÜòNÖR_ Ñh–þÐÜb„DfXõ›ªªªäää¿þõ¯«V­:~ü¸Ug’¼äâ‹/†yhçdK’÷ ]33V?­žø9=Ó- rssçb ´@Z ¡:µZÜÉZ¶Àų¢Ú…¢µ6ü.¸~ýz) Ÿxýõ×o¾ùæÕ«W?õÔSÅÅÅ #à. O<ñ>½úê«¿÷½ïegg[:ô?%½J «æd5¿¤¤äÙgŸýÜH`e*++ñúÌ3Ï`‰5Ç¥Ûâȉòòò×^{ ›kòÉ' "##o¹åy0%%妛n:xð Òüþ÷¿_·nÝ5×\óÃþ0..ŽH $´@'·@˧÷I}ºËEµ¢š…R½Pæâ7‰‰‰kÖ¬‘ÒûÛßz衤¤$L?ûÙÏž{î9iyùl_þò—0VÀ¿ùÍož~úi32~‹WùÞiÆiK¬~úÒK/aeR¦xà^~ùeØÛ‹/¾øÈ#Hõõ­o} _”î”&'6nÜøàƒª³²²~ò“Ÿ`%ÓÓÓï¾ûîÝ»wKßÚµkÞJiüæ½÷ÞGÿÕ¯~E ¤rþˆèÔsShö#©/ÈÏÏ_J+Z²[Úö›ÂÂÂK.¹DJßyç±±±Ra¢%iy«÷çÌÉɹá†ÌÈø-^å›v§-±ú)B·èèh)uë­·J™°«Ò)Ž?Ž/Ji9qÇw„‡‡ÃÿÒÒÒÿa Q³ˆ ¿ûÝïJµüè£nذAJßvÛm‡’Òò´@Z ¡:-źq“çÖÖ—èÇ¥¾}ú’ùÐ߇چßÄÅÅ]wÝuRúÊ+¯¼dŠ‹/¾‹áÕlù£G" [µj•tT ˜9ñ[ãL³@‰ø´Ä‚+®¸"//OJ#·rfñˆDñE¼EÅ!!ê‚.>‡´†ÈT*•W]u,VŠÞJ5nuaZ -Ð4o¸`©^Tñ¹çÖJ}J¥Z2² ¥ ÂØ`*ˆüqÉin¿ýöøøx3+2ö'„b[¶lA€¨Ñh`9øHr#x |HJ'''Kùò§à¢‹.’EÖÀ’–™ø™!8Ö‹·ø‹›o¾988+€ Ïßß_¶+95 ±ìè±/½ôÒ‹/¾¸~ýz9Óê´@Z ¡:³ZJ¾A\ai|ÈFH4/ŠçäL†þüç?¯^½:44Tri" ƃÐ*<<ü‰'ž0ó§µk×îÙ³á׉'à%øH3Å7¾ñ LVVò}ôQ)_þ¬Y³?+¿-<V#??Kâ7³³³Õj5~c‘ÌÌÌgŸ}öþûï›âÞ{ïýÝï~‡:Â+ÂÐð)þýßÿÝÒ_yå•ûî»/ 11ÑÏÏï±Ç“§oBžœiaZ -óG´@§­K( ]²ÍÍ<‘aÂϾÿýï#À’ nôÖ[o!¼üòËïºë.¸2±°¼À¾}ûð饗^ºnÝ:,‰ ¦À|ýë_Ç·n¼ñF)_:8 WËšâÕW_½úꫥÕ1\ªÑ¦H™ O>ùäš)À[)ó§?ýé5×\ƒÌçŸkbfˆAáë·ÝvÛe—]vçw"f•O]7òÿZ]˜H $´@WŒå“b–À‡,ã¡ ¡``»òŒ@Ô•c„Ú)“ɘ‘UÀÞ¸ ™ÙÅ´@B tõ(0¯¬½!qA°çÓ -ÐÕ-Ê.¬e‡H\ uv¦æÀŽ‚Ð]Ë¥X0#«€ó‚ÄéIWåÎÿÑ9D t¹¹@Š¢h„èÒQ EQ´@B ¤R-Z -¢h„s´@ÎR-0 $L‰žEÙÚ; B tNºÏœ­l4T4PeEhh#ì(-BˆÓ¹@×­KB!´@B!„H!„Ð !„87œ tݺ$„B $„Bh„B-Ð1>Ê4ÓL3ÍôÜÓ´@B!„H!„Ð !„Z !„Z !„B $„Bh„B-B¡B!´@B!„H!„Ð !„Z !„B $„BVÿ¹:þ¯¹+ßIEND®B`‚libalog-0.5.0/doc/asciidoc.css000066400000000000000000000236411241767602000161750ustar00rootroot00000000000000body { font-family: Georgia,serif; } h1, h2, h3, h4, h5, h6, div.title, caption.title, thead, p.table.header, #toctitle, #author, #revnumber, #revdate, #revremark, #footer { font-family: Arial,Helvetica,sans-serif; } body { background-color: #f1f1f1; } table.main { width: 80%; margin: 1em 10% 1em 10%; background: none repeat scroll 0 0 #ffffff; -webkit-border-radius: 10px; -webkit-box-shadow: 1px 1px 6px rgba(0, 0, 0, 0.6); -moz-border-radius: 10px; -moz-box-shadow: 1px 1px 6px rgba(0, 0, 0, 0.6); border-radius: 10px; box-shadow: 1px 1px 6px rgba(0, 0, 0, 0.6); } td.header { background-color: #666262; padding: 1px 15px 1px; border-bottom: 5px solid #4183c4; -webkit-border-top-left-radius: 10px; -webkit-border-top-right-radius: 10px; -moz-border-radius-topleft: 10px; -moz-border-radius-topright: 10px; border-top-left-radius: 10px; border-top-right-radius: 10px; } td.content { padding: 1px 15px 40px; } td.footer { background-color: #666262; border-top: 8px solid #4183c4; -webkit-border-bottom-right-radius: 10px; -webkit-border-bottom-left-radius: 10px; -moz-border-radius-bottomright: 10px; -moz-border-radius-bottomleft: 10px; border-bottom-right-radius: 10px; border-bottom-left-radius: 10px; } a { outline: none; } a:link, a:visited { color: #4183c4; text-decoration: none; } a:hover { text-decoration: underline; } em { font-style: italic; color: gray; } strong { font-weight: bold; color: #083194; } h2, h3, h4, h5, h6 { color: #4183c4; margin-top: 1.2em; margin-bottom: 0.5em; line-height: 1.3; } h1 { color: white; } h2, h3 { border-bottom: 1px solid silver; } h2 { padding-top: 0.5em; } h3 { float: left; } h3 + * { clear: left; } h5 { font-size: 1.0em; } div.sectionbody { margin-left: 0; } hr { border: 1px solid silver; } p { margin-top: 0.5em; margin-bottom: 0.5em; } ul, ol, li > p { margin-top: 0; } ul > li { color: #aaa; } ul > li > * { color: black; } pre { padding: 0; margin: 0; } #author { color: #527bbd; font-weight: bold; font-size: 1.1em; } #email { } #revnumber, #revdate, #revremark { } #footer { font-size: x-small; margin-bottom: 4.0em; } #footer-text { color: #f1f1f1; float: right; padding-bottom: 0.5em; margin-right: 4px; } #footer-badges { float: right; padding-bottom: 0.5em; } #preamble { margin-top: 1.5em; margin-bottom: 1.5em; } div.imageblock, div.exampleblock, div.verseblock, div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock, div.admonitionblock { margin-top: 1.0em; margin-bottom: 1.5em; } div.admonitionblock { margin-top: 2.0em; margin-bottom: 2.0em; margin-right: 10%; color: #606060; } div.content { /* Block element content. */ padding: 0; } /* Block element titles. */ div.title, caption.title { color: #527bbd; font-weight: bold; text-align: left; margin-top: 1.0em; margin-bottom: 0.5em; } div.title + * { margin-top: 0; } td div.title:first-child { margin-top: 0.0em; } div.content div.title:first-child { margin-top: 0.0em; } div.content + div.title { margin-top: 0.0em; } div.sidebarblock > div.content { background: #ffffee; border: 1px solid #dddddd; border-left: 4px solid #f0f0f0; padding: 0.5em; } div.listingblock > div.content { border: 1px solid #dddddd; border-left: 5px solid #f0f0f0; background: #f8f8f8; padding: 0.5em; } div.quoteblock, div.verseblock { padding-left: 1.0em; margin-left: 1.0em; margin-right: 10%; border-left: 5px solid #f0f0f0; color: #888; } div.quoteblock > div.attribution { padding-top: 0.5em; text-align: right; } div.verseblock > pre.content { font-family: inherit; font-size: inherit; } div.verseblock > div.attribution { padding-top: 0.75em; text-align: left; } /* DEPRECATED: Pre version 8.2.7 verse style literal block. */ div.verseblock + div.attribution { text-align: left; } div.admonitionblock .icon { vertical-align: top; font-size: 1.1em; font-weight: bold; text-decoration: underline; color: #527bbd; padding-right: 0.5em; } div.admonitionblock td.content { padding-left: 0.5em; border-left: 3px solid #dddddd; } div.exampleblock > div.content { border-left: 3px solid #dddddd; padding-left: 0.5em; } div.imageblock div.content { padding-left: 0; } span.image img { border-style: none; } a.image:visited { color: white; } dl { margin-top: 0.8em; margin-bottom: 0.8em; } dt { margin-top: 0.5em; margin-bottom: 0; font-style: normal; color: gray; } dd > *:first-child { margin-top: 0.1em; } ul, ol { list-style-position: outside; } ol.arabic { list-style-type: decimal; } ol.loweralpha { list-style-type: lower-alpha; } ol.upperalpha { list-style-type: upper-alpha; } ol.lowerroman { list-style-type: lower-roman; } ol.upperroman { list-style-type: upper-roman; } div.compact ul, div.compact ol, div.compact p, div.compact p, div.compact div, div.compact div { margin-top: 0.1em; margin-bottom: 0.1em; } tfoot { font-weight: bold; } td > div.verse { white-space: pre; } div.hdlist { margin-top: 0.8em; margin-bottom: 0.8em; } div.hdlist tr { padding-bottom: 15px; } dt.hdlist1.strong, td.hdlist1.strong { font-weight: bold; } td.hdlist1 { vertical-align: top; font-style: normal; padding-right: 0.8em; color: gray; } td.hdlist2 { vertical-align: top; } div.hdlist.compact tr { margin: 0; padding-bottom: 0; } .comment { background: yellow; } .footnote, .footnoteref { font-size: 0.8em; } span.footnote, span.footnoteref { vertical-align: super; } #footnotes { margin: 20px 0 20px 0; padding: 7px 0 0 0; } #footnotes div.footnote { margin: 0 0 5px 0; } #footnotes hr { border: none; border-top: 1px solid silver; height: 1px; text-align: left; margin-left: 0; width: 20%; min-width: 100px; } div.colist td { padding-right: 0.5em; padding-bottom: 0.3em; vertical-align: top; } div.colist td img { margin-top: 0.3em; } @media print { #footer-badges { display: none; } } #toc { margin-bottom: 2.5em; } #toctitle { color: #527bbd; font-size: 1.1em; font-weight: bold; margin-top: 1.0em; margin-bottom: 0.1em; } div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 { margin-top: 0; margin-bottom: 0; } div.toclevel2 { margin-left: 2em; font-size: 0.9em; } div.toclevel3 { margin-left: 4em; font-size: 0.9em; } div.toclevel4 { margin-left: 6em; font-size: 0.9em; } span.aqua { color: aqua; } span.black { color: black; } span.blue { color: blue; } span.fuchsia { color: fuchsia; } span.gray { color: gray; } span.green { color: green; } span.lime { color: lime; } span.maroon { color: maroon; } span.navy { color: navy; } span.olive { color: olive; } span.purple { color: purple; } span.red { color: red; } span.silver { color: silver; } span.teal { color: teal; } span.white { color: white; } span.yellow { color: yellow; } span.aqua-background { background: aqua; } span.black-background { background: black; } span.blue-background { background: blue; } span.fuchsia-background { background: fuchsia; } span.gray-background { background: gray; } span.green-background { background: green; } span.lime-background { background: lime; } span.maroon-background { background: maroon; } span.navy-background { background: navy; } span.olive-background { background: olive; } span.purple-background { background: purple; } span.red-background { background: red; } span.silver-background { background: silver; } span.teal-background { background: teal; } span.white-background { background: white; } span.yellow-background { background: yellow; } span.big { font-size: 2em; } span.small { font-size: 0.6em; } span.underline { text-decoration: underline; } span.overline { text-decoration: overline; } span.line-through { text-decoration: line-through; } /* * xhtml11 specific * * */ tt { font-family: monospace; font-size: inherit; color: gray; } div.tableblock { margin-top: 1.0em; margin-bottom: 1.5em; } div.tableblock > table { border: 3px solid #527bbd; } thead, p.table.header { font-weight: bold; color: #527bbd; } p.table { margin-top: 0; } /* Because the table frame attribute is overriden by CSS in most browsers. */ div.tableblock > table[frame="void"] { border-style: none; } div.tableblock > table[frame="hsides"] { border-left-style: none; border-right-style: none; } div.tableblock > table[frame="vsides"] { border-top-style: none; border-bottom-style: none; } /* * html5 specific * * */ .monospaced { font-family: monospace; font-size: inherit; color: gray; } table.tableblock { margin-top: 1.0em; margin-bottom: 1.5em; } thead, p.tableblock.header { font-weight: bold; color: #527bbd; } p.tableblock { margin-top: 0; } table.tableblock { border-width: 3px; border-spacing: 0px; border-style: solid; border-color: #527bbd; border-collapse: collapse; } th.tableblock, td.tableblock { border-width: 1px; padding: 4px; border-style: solid; border-color: #527bbd; } table.tableblock.frame-topbot { border-left-style: hidden; border-right-style: hidden; } table.tableblock.frame-sides { border-top-style: hidden; border-bottom-style: hidden; } table.tableblock.frame-none { border-style: hidden; } th.tableblock.halign-left, td.tableblock.halign-left { text-align: left; } th.tableblock.halign-center, td.tableblock.halign-center { text-align: center; } th.tableblock.halign-right, td.tableblock.halign-right { text-align: right; } th.tableblock.valign-top, td.tableblock.valign-top { vertical-align: top; } th.tableblock.valign-middle, td.tableblock.valign-middle { vertical-align: middle; } th.tableblock.valign-bottom, td.tableblock.valign-bottom { vertical-align: bottom; } /* * manpage specific * * */ body.manpage h1 { padding-top: 0.5em; padding-bottom: 0.5em; border-top: 2px solid silver; border-bottom: 2px solid silver; } body.manpage h2 { border-style: none; } body.manpage div.sectionbody { margin-left: 3em; } @media print { body.manpage div#toc { display: none; } } libalog-0.5.0/doc/index000066400000000000000000000105271241767602000147360ustar00rootroot00000000000000Alog ==== * link:README.html[README] * link:CHANGELOG.html[CHANGELOG] * http://www.codelabs.ch/download/[Download] Overview -------- Alog is a stackable logging framework for Ada. It aims to be straight forward to use and easily extendable. It provides support for various logger types, log facilities, loglevel policies and message transformations. image:alog-arch.png[Framework Architecture] Logger ~~~~~~ Logger instances are used to manage an arbitrary number of log facilities and message transformations. Various logger types exist which are suitable for different scenarios: Logger:: This is the basic Alog logger type. This logger is easy to use and good enough for most situations. However, it does not provide thread safety. Tasked Logger:: The Alog tasked logger encapsulates a basic logger instance inside a server task to provide safe concurrent logging. Since calls to this logger are potentially blocking operations, it cannot be used from within a protected action. Active Logger:: The Alog active logger provides task safe concurrent logging from any context. Facility ~~~~~~~~ Another basic entity in the Alog framework is called a Facility. Facilities are log destinations and used to log messages to different backends, e.g. a file or a database. Currently, the framework provides the following log facilities: File_Descriptor:: Writes log messages to file or console. Syslog:: Writes log messages to syslog. Transformation ~~~~~~~~~~~~~~ Transformations are used to modify a log message before it is passed on to a facility. The following message transformations are available: Casing (toUpper / toLower):: Convert a log message to upper/lower case. Policy ~~~~~~ Alog supports source and destination filtering by means of loglevel policies. Refer to the example section for information on how to setup such policies. Examples -------- The examples presented in this section will give an introduction on how to use the Alog framework in your own project. Logger ~~~~~~ The following example uses a basic logger instance to log messages to standard output. Furthermore, a file based facility is attached which writes log messages to a file. [source,ada] --------------------------------------------------------------------- include::../examples/logger_example1.adb[] --------------------------------------------------------------------- The logger will take care about cleaning up all the attached facilities when it goes out of scope. However, you can do this explicitly by calling `Logger.Clear` as well. Facility ~~~~~~~~ The following code sets up a file descriptor based facility to log messages to a file. If the file already exists, it will be overwritten. [source,ada] --------------------------------------------------------------------- include::../examples/facility_example1.adb[] --------------------------------------------------------------------- Policy ~~~~~~ The first policy example uses the policy database of Alog to specify source specific loglevels. It shows how logging policies can be used to filter log messages depending on their source. [source,ada] --------------------------------------------------------------------- include::../examples/policy_example1.adb[] --------------------------------------------------------------------- The second policy example demonstrates the usage of destination filtering. Only log messages with loglevel `Error` or higher are written to the application error logfile. It shows how logging policies can be used to filter log messages depending on the destination (facility name). [source,ada] --------------------------------------------------------------------- include::../examples/policy_example2.adb[] --------------------------------------------------------------------- Browse the source ----------------- - You can browse the Alog source code with gitweb http://git.codelabs.ch/?p=alog.git[here]. Licence ------- -------------------------------------------------------------------------------- Copyright (C) 2008-2014 Reto Buerki Copyright (C) 2008-2014 Adrian-Ken Rueegsegger Alog is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. -------------------------------------------------------------------------------- libalog-0.5.0/doc/page.conf000066400000000000000000000465511241767602000154750ustar00rootroot00000000000000[miscellaneous] outfilesuffix=.html [attributes] basebackend=html basebackend-html= basebackend-xhtml11= [replacements2] # Line break. (?m)^(.*)\s\+$=\1
[replacements] ifdef::asciidoc7compatible[] # Superscripts. \^(.+?)\^=\1 # Subscripts. ~(.+?)~=\1 endif::asciidoc7compatible[] [ruler-blockmacro]
[pagebreak-blockmacro]
[blockdef-pass] asciimath-style=template="asciimathblock",subs=[] latexmath-style=template="latexmathblock",subs=[] [macros] # math macros. # Special characters are escaped in HTML math markup. (?su)[\\]?(?Pasciimath|latexmath):(?P\S*?)\[(?P.*?)(?asciimath|latexmath)::(?P\S*?)(\[(?P.*?)\])$=#[specialcharacters] [asciimath-inlinemacro] `{passtext}` [asciimath-blockmacro]
{title}
`{passtext}`
[asciimathblock]
{title}
`|`
[latexmath-inlinemacro] {passtext} [latexmath-blockmacro]
{title}
{passtext}
[latexmathblock]
{title}
|
[image-inlinemacro] {data-uri%}{alt={target}} {data-uri#}{alt={target}} {link#} [image-blockmacro]
{caption={figure-caption} {counter:figure-number}. }{title}
[unfloat-blockmacro]
[indexterm-inlinemacro] # Index term. {empty} [indexterm2-inlinemacro] # Index term. # Single entry index term that is visible in the primary text flow. {1} [footnote-inlinemacro] # footnote:[].
[{0}]
[footnoteref-inlinemacro] # footnoteref:[], create reference to footnote. {2%}
[{1}]
# footnoteref:[,], create footnote with ID. {2#}
[{2}]
[callout-inlinemacro] ifndef::icons[] <{index}> endif::icons[] ifdef::icons[] ifndef::data-uri[] {index} endif::data-uri[] ifdef::data-uri[] {index} endif::data-uri[] endif::icons[] # Comment line macros. [comment-inlinemacro] {showcomments#}
{passtext}
[comment-blockmacro] {showcomments#}

{passtext}

[literal-inlinemacro] # Inline literal. {passtext} # List tags. [listtags-bulleted] list=
{title?
{title}
}
    |
item=
  • |
  • text=

    |

    [listtags-numbered] # The start attribute is not valid XHTML 1.1 but all browsers support it. list=
    {title?
    {title}
    }
      |
    item=
  • |
  • text=

    |

    [listtags-labeled] list=
    {title?
    {title}
    }
    |
    entry= label= term=
    |
    item=
    |
    text=

    |

    [listtags-horizontal] list=
    {title?
    {title}
    }{labelwidth?}{itemwidth?}|
    label=| term=|
    entry=| item=| text=

    |

    [listtags-qanda] list=
    {title?
    {title}
    }
      |
    entry=
  • |
  • label= term=

    |

    item= text=

    |

    [listtags-callout] ifndef::icons[] list=
    {title?
    {title}
    }
      |
    item=
  • |
  • text=

    |

    endif::icons[] ifdef::icons[] list=
    {title?
    {title}
    }|
    ifndef::data-uri[] item={listindex}| endif::data-uri[] ifdef::data-uri[] item={listindex}| endif::data-uri[] text=| endif::icons[] [listtags-glossary] list=
    {title?
    {title}
    }
    |
    label= entry= term=
    |
    item=
    |
    text=

    |

    [listtags-bibliography] list=
    {title?
    {title}
    }
      |
    item=
  • |
  • text=

    |

    [tags] # Quoted text. emphasis={1?}|{1?} strong={1?}|{1?} monospaced={1?}|{1?} singlequoted={lsquo}{1?}|{1?}{rsquo} doublequoted={ldquo}{1?}|{1?}{rdquo} unquoted={1?}|{1?} superscript={1?}|{1?} subscript={1?}|{1?} ifdef::deprecated-quotes[] # Override with deprecated quote attributes. emphasis={role?}|{role?} strong={role?}|{role?} monospaced={role?}|{role?} singlequoted={role?}{1,2,3?}{amp}#8216;|{amp}#8217;{1,2,3?}{role?} doublequoted={role?}{1,2,3?}{amp}#8220;|{amp}#8221;{1,2,3?}{role?} unquoted={role?}{1,2,3?}|{1,2,3?}{role?} superscript={role?}|{role?} subscript={role?}|{role?} endif::deprecated-quotes[] # Inline macros [http-inlinemacro] {0={name}:{target}} [https-inlinemacro] {0={name}:{target}} [ftp-inlinemacro] {0={name}:{target}} [file-inlinemacro] {0={name}:{target}} [irc-inlinemacro] {0={name}:{target}} [mailto-inlinemacro] {0={target}} [link-inlinemacro] {0={target}} [callto-inlinemacro] {0={target}} # anchor:id[text] [anchor-inlinemacro] # [[id,text]] [anchor2-inlinemacro] # [[[id]]] [anchor3-inlinemacro] [{1}] # xref:id[text] [xref-inlinemacro] {0=[{target}]} # <> [xref2-inlinemacro] {2=[{1}]} # Special word substitution. [emphasizedwords] {words} [monospacedwords] {words} [strongwords] {words} # Paragraph substitution. [paragraph]
    {title?
    {title}
    }

    |

    [admonitionparagraph] template::[admonitionblock] # Delimited blocks. [listingblock]
    {caption=}{title}
    
    |
    
    [literalblock]
    {title}
    
    |
    
    [sidebarblock]
    {title}
    |
    [openblock]
    {title}
    |
    [partintroblock] template::[openblock] [abstractblock] template::[quoteblock] [quoteblock]
    {title}
    |
    {citetitle}{attribution?
    } — {attribution}
    [verseblock]
    {title}
    |
    
    {citetitle}{attribution?
    } — {attribution}
    [exampleblock]
    {caption={example-caption} {counter:example-number}. }{title}
    |
    [admonitionblock]
    {data-uri%}{icons#}{caption} {data-uri#}{icons#}{caption} {icons%}
    {caption}
    {title}
    |
    # Tables. [tabletags-default] colspec= bodyrow=| headdata=| bodydata=| paragraph=

    |

    [tabletags-header] paragraph=

    |

    [tabletags-emphasis] paragraph=

    |

    [tabletags-strong] paragraph=

    |

    [tabletags-monospaced] paragraph=

    |

    [tabletags-verse] bodydata=
    |
    paragraph= [tabletags-literal] bodydata=
    |
    paragraph= [tabletags-asciidoc] bodydata=
    |
    paragraph= [table]
    {colspecs} {headrows#} {headrows} {headrows#} {footrows#} {footrows} {footrows#} {bodyrows}
    {caption={table-caption} {counter:table-number}. }{title}
    #-------------------------------------------------------------------- [floatingtitle] {title} [preamble] # Untitled elements between header and first section title.
    |
    # Document sections. [sect0] {title} | [sect1]
    {numbered?{sectnum} }{title}
    |
    [sect2]
    {numbered?{sectnum} }{title} |
    [sect3]
    {numbered?{sectnum} }{title} |
    [sect4]
    {title} |
    [appendix]
    {numbered?{sectnum} }{appendix-caption} {counter:appendix-number:A}: {title}
    |
    [toc]
    {toc-title}
    [header] {title} {title%}{doctitle=} ifdef::linkcss[] ifdef::quirks[] endif::quirks[] ifdef::pygments[] ifdef::toc2[] endif::linkcss[] ifndef::linkcss[] endif::linkcss[] ifndef::disable-javascript[] ifdef::linkcss[] endif::linkcss[] ifndef::linkcss[] endif::linkcss[] endif::disable-javascript[] ifdef::asciimath[] ifdef::linkcss[] endif::linkcss[] ifndef::linkcss[] endif::linkcss[] endif::asciimath[] ifdef::latexmath[] ifdef::linkcss[] endif::linkcss[] ifndef::linkcss[] endif::linkcss[] endif::latexmath[] {docinfo1,docinfo2#}{include:{docdir}/docinfo.html} {docinfo,docinfo2#}{include:{docdir}/{docname}-docinfo.html} template::[docinfo]
    # Article, book header. ifndef::doctype-manpage[]
    endif::doctype-manpage[] # Man page header. ifdef::doctype-manpage[] endif::doctype-manpage[] [footer]
    ifdef::doctype-manpage[] [synopsis] template::[sect1] endif::doctype-manpage[] ifdef::quirks[] include::xhtml11-quirks.conf[] endif::quirks[] libalog-0.5.0/examples/000077500000000000000000000000001241767602000147505ustar00rootroot00000000000000libalog-0.5.0/examples/Makefile000066400000000000000000000016071241767602000164140ustar00rootroot00000000000000# # Copyright (c) 2009, # Reto Buerki, Adrian-Ken Rueegsegger # # This file is part of Alog. # # Alog is free software; you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as published # by the Free Software Foundation; either version 2.1 of the License, or # (at your option) any later version. # # Alog is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with Alog; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, # MA 02110-1301 USA # all: build_examples build_examples: @gprbuild -p -Palog_examples clean: @rm -rf obj libalog-0.5.0/examples/alog_examples.gpr000066400000000000000000000024421241767602000203040ustar00rootroot00000000000000-- -- Copyright (c) 2009, -- Reto Buerki, Adrian-Ken Rueegsegger -- -- This file is part of Alog. -- -- Alog is free software; you can redistribute it and/or modify -- it under the terms of the GNU Lesser General Public License as published -- by the Free Software Foundation; either version 2.1 of the License, or -- (at your option) any later version. -- -- Alog is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public License -- along with Alog; if not, write to the Free Software -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, -- MA 02110-1301 USA -- with "../alog"; with "../alog_common"; project Alog_Examples is for Source_Dirs use ("."); for Object_Dir use "obj"; for Main use ("logger_example1.adb", "facility_example1.adb", "policy_example1.adb", "policy_example2.adb", "syslog_example1.adb"); package Compiler is for Default_Switches ("ada") use Alog_Common.Compiler_Switches; end Compiler; package Builder is for Default_Switches ("ada") use ("-g"); end Builder; end Alog_Examples; libalog-0.5.0/examples/facility_example1.adb000066400000000000000000000013611241767602000210210ustar00rootroot00000000000000with Alog.Log_Request; with Alog.Facilities.File_Descriptor; use Alog; -- Alog file descriptor facility example. procedure Facility_Example1 is Facility : Facilities.File_Descriptor.Instance; begin -- Enable writing of loglevels. Facility.Toggle_Write_Loglevel (State => True); -- Use '/tmp/alog.log' as logfile, overwrite existing file. Facility.Set_Logfile (Path => "/tmp/alog.log", Append => False); -- Let the facility process a log request with loglevel 'Warning'. Facility.Process (Request => Log_Request.Create (Level => Warning, Message => "This is a testmessage from Alog FD facility")); -- Teardown the facility. Facility.Teardown; end Facility_Example1; libalog-0.5.0/examples/logger_example1.adb000066400000000000000000000016261241767602000205000ustar00rootroot00000000000000with 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; libalog-0.5.0/examples/policy_example1.adb000066400000000000000000000027451241767602000205230ustar00rootroot00000000000000with Alog.Policy_DB; with Alog.Logger; use Alog; -- Alog source loglevel policy example. procedure Policy_Example1 is Log : Logger.Instance (Init => True); begin -- Set default loglevel to 'Info'. Policy_DB.Set_Default_Loglevel (Level => Info); -- Set source specific loglevel for all 'Example' sources to 'Debug'. Policy_DB.Set_Loglevel (Identifier => "Example.*", Level => Debug); -- This message will be logged because it matches a source specific -- loglevel (Example.*). if Policy_DB.Accept_Src (Identifier => "Example.Source1", Level => Debug) then Log.Log_Message (Source => "Example.Source1", Level => Debug, Msg => "This is a testmessage"); end if; -- This message will not be logged because of the configured default 'Info' -- loglevel. There's no configured source loglevel for 'Source2'. if Policy_DB.Accept_Src (Identifier => "Source2", Level => Debug) then Log.Log_Message (Source => "Source2", Level => Debug, Msg => "This will not be logged"); end if; -- No source specified, will not be logged because of the default 'Info' -- loglevel. if Policy_DB.Accept_Src (Level => Debug) then Log.Log_Message (Level => Debug, Msg => "This will not be logged"); end if; end Policy_Example1; libalog-0.5.0/examples/policy_example2.adb000066400000000000000000000021331241767602000205130ustar00rootroot00000000000000with Alog.Policy_DB; with Alog.Logger; with Alog.Facilities.File_Descriptor; use Alog; -- Alog destination loglevel policy example. procedure Policy_Example2 is Log : Logger.Instance (Init => True); Errors : constant Facilities.File_Descriptor.Handle := new Facilities.File_Descriptor.Instance; begin -- Write all error messages to '/tmp/errors.log'. Errors.Set_Logfile (Path => "/tmp/errors.log"); Errors.Set_Name (Name => "Application_Errors"); Errors.Toggle_Write_Loglevel (State => True); -- Set loglevel policy to 'Error' for destination 'Application_Errors'. Policy_DB.Set_Loglevel (Identifier => "Application_Errors", Level => Error); Log.Attach_Facility (Facility => Facilities.Handle (Errors)); -- This message will appear on stdout, but not in the error logfile. Log.Log_Message (Level => Info, Msg => "This is not an error"); -- This message will also be written to the error logfile. Log.Log_Message (Level => Error, Msg => "This is an error"); end Policy_Example2; libalog-0.5.0/examples/syslog_example1.adb000066400000000000000000000007541241767602000205420ustar00rootroot00000000000000with Alog.Logger; with Alog.Facilities.Syslog; use Alog; -- Alog syslog example. procedure Syslog_Example1 is Log : Logger.Instance (Init => False); Syslog : constant Facilities.Syslog.Handle := new Facilities.Syslog.Instance; begin Log.Attach_Facility (Facility => Facilities.Handle (Syslog)); Syslog.Set_Origin (Value => Facilities.Syslog.LOG_DAEMON); Log.Log_Message (Level => Debug, Msg => "This is a testmessage"); end Syslog_Example1; libalog-0.5.0/gnat/000077500000000000000000000000001241767602000140635ustar00rootroot00000000000000libalog-0.5.0/gnat/alog.gpr000066400000000000000000000025451241767602000155250ustar00rootroot00000000000000-- -- Copyright (c) 2011, -- Reto Buerki, Adrian-Ken Rueegsegger -- -- This file is part of Alog. -- -- Alog is free software; you can redistribute it and/or modify -- it under the terms of the GNU Lesser General Public License as published -- by the Free Software Foundation; either version 2.1 of the License, or -- (at your option) any later version. -- -- Alog is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public License -- along with Alog; if not, write to the Free Software -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, -- MA 02110-1301 USA -- -- This project file is designed to help build applications that use -- Alog. Here is an example of how to use this project file: -- -- with "alog"; -- project Example is -- for Object_Dir use "obj"; -- for Exec_Dir use "."; -- for Main use ("example"); -- end Example; project Alog is for Source_Dirs use ("../../include/alog"); for Library_Name use "alog"; for Library_Dir use "../../lib"; for Library_ALI_Dir use "../../lib/alog"; for Library_Kind use "dynamic"; for Externally_Built use "true"; end Alog; libalog-0.5.0/src/000077500000000000000000000000001241767602000137215ustar00rootroot00000000000000libalog-0.5.0/src/alog-active_logger.adb000066400000000000000000000164621241767602000201340ustar00rootroot00000000000000-- -- Copyright (c) 2009-2012, -- Reto Buerki, Adrian-Ken Rueegsegger -- -- This file is part of Alog. -- -- Alog is free software; you can redistribute it and/or modify -- it under the terms of the GNU Lesser General Public License as published -- by the Free Software Foundation; either version 2.1 of the License, or -- (at your option) any later version. -- -- Alog is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public License -- along with Alog; if not, write to the Free Software -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, -- MA 02110-1301 USA -- with Ada.Task_Identification; with Alog.Log_Request; package body Alog.Active_Logger is ------------------------------------------------------------------------- procedure All_Done (Logger : in out Instance) is begin Logger.Message_Queue.All_Done; end All_Done; ------------------------------------------------------------------------- procedure Attach_Default_Facility (Logger : in out Instance) is begin Logger.Backend.Attach_Default_Facility; end Attach_Default_Facility; ------------------------------------------------------------------------- procedure Attach_Facility (Logger : in out Instance; Facility : Facilities.Handle) is begin Logger.Backend.Attach_Facility (Facility); end Attach_Facility; ------------------------------------------------------------------------- procedure Attach_Transform (Logger : in out Instance; Transform : Transforms.Handle) is begin Logger.Backend.Attach_Transform (Transform); end Attach_Transform; ------------------------------------------------------------------------- procedure Clear (Logger : in out Instance) is begin Logger.Backend.Clear; end Clear; ------------------------------------------------------------------------- procedure Detach_Default_Facility (Logger : in out Instance) is begin Logger.Backend.Detach_Default_Facility; end Detach_Default_Facility; ------------------------------------------------------------------------- procedure Detach_Facility (Logger : in out Instance; Name : String) is begin Logger.Backend.Detach_Facility (Name); end Detach_Facility; ------------------------------------------------------------------------- procedure Detach_Transform (Logger : in out Instance; Name : String) is begin Logger.Backend.Detach_Transform (Name); end Detach_Transform; ------------------------------------------------------------------------- function Facility_Count (Logger : Instance) return Natural is F_Count : Natural; begin Logger.Backend.Facility_Count (Count => F_Count); return F_Count; end Facility_Count; ------------------------------------------------------------------------- procedure Finalize (Helper : in out Shutdown_Helper) is begin Helper.Logger.Shutdown; end Finalize; ------------------------------------------------------------------------- function Get_Queue_Length (Logger : Instance) return Natural is begin return Logger.Message_Queue.Length; end Get_Queue_Length; ------------------------------------------------------------------------- function Is_Terminated (Logger : Instance) return Boolean is begin return Logger.Backend'Terminated and then Logger.Logger_Task'Terminated; end Is_Terminated; ------------------------------------------------------------------------- procedure Iterate (Logger : in out Instance; Process : Tasked_Logger.Facility_Update_Handle) is begin Logger.Backend.Iterate (Process); end Iterate; ------------------------------------------------------------------------- procedure Log_Message (Logger : in out Instance; Level : Log_Level; Msg : String; Source : String := "") is begin Logger.Message_Queue.Put (Element => Log_Request.Create (ID => Ada.Task_Identification.Current_Task, Source => Source, Level => Level, Message => Msg)); end Log_Message; ------------------------------------------------------------------------- procedure Set_Except_Handler (Logger : Instance; Proc : Exceptions.Exception_Handler) is begin Logger.Backend.Set_Except_Handler (Proc => Proc); end Set_Except_Handler; ------------------------------------------------------------------------- procedure Shutdown (Logger : in out Instance; Flush : Boolean := True) is begin if Logger.Is_Terminated then return; end if; if Flush then Logger.Message_Queue.All_Done; end if; Logger.Clear; Logger.Trigger.Shutdown; Logger.Backend.Shutdown; end Shutdown; ------------------------------------------------------------------------- function Transform_Count (Logger : Instance) return Natural is T_Count : Natural; begin Logger.Backend.Transform_Count (Count => T_Count); return T_Count; end Transform_Count; ------------------------------------------------------------------------- procedure Update (Logger : in out Instance; Name : String; Process : Tasked_Logger.Facility_Update_Handle) is begin Logger.Backend.Update (Name => Name, Process => Process); end Update; ------------------------------------------------------------------------- protected body Trigger_Type is ---------------------------------------------------------------------- procedure Shutdown is begin Shutdown_Requested := True; end Shutdown; ---------------------------------------------------------------------- entry Stop when Shutdown_Requested is begin null; end Stop; end Trigger_Type; ------------------------------------------------------------------------- task body Logging_Task is begin select Parent.Trigger.Stop; then abort Log_Loop : loop declare Current_Request : Log_Request.Instance; begin Parent.Message_Queue.Get (Element => Current_Request); Parent.Backend.Log_Message (Source => Current_Request.Get_Source, Level => Current_Request.Get_Log_Level, Msg => Current_Request.Get_Message, Caller => Current_Request.Get_Caller_ID); Parent.Message_Queue.Done; exception when Program_Error => -- The Queue has terminated, let's shutdown. exit Log_Loop; when others => -- Ignore other errors and resume normal operation. null; end; end loop Log_Loop; end select; end Logging_Task; end Alog.Active_Logger; libalog-0.5.0/src/alog-active_logger.ads000066400000000000000000000145051241767602000201510ustar00rootroot00000000000000-- -- Copyright (c) 2009-2012, -- Reto Buerki, Adrian-Ken Rueegsegger -- -- This file is part of Alog. -- -- Alog is free software; you can redistribute it and/or modify -- it under the terms of the GNU Lesser General Public License as published -- by the Free Software Foundation; either version 2.1 of the License, or -- (at your option) any later version. -- -- Alog is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public License -- along with Alog; if not, write to the Free Software -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, -- MA 02110-1301 USA -- with Ada.Finalization; with Alog.Facilities; with Alog.Transforms; with Alog.Tasked_Logger; with Alog.Protected_Containers; with Alog.Exceptions; -- Active Logger instance. This logger is an active object and implements -- concurrent, asynchronous logging. It provides the same functionality as the -- 'simple' logger. package Alog.Active_Logger is type Instance (Init : Boolean) is tagged limited private; -- Active logger instance. Incoming messages (via Log_Message) are put into -- a request queue. This queue is consumed by a logging task. -- -- By default exceptions which occur during asynchronous processing are -- printed to standard error. Use the Set_Except_Handler procedure to -- register a custom exception handler. type Handle is access all Instance; -- Handle to active logger type. procedure Attach_Facility (Logger : in out Instance; Facility : Facilities.Handle); -- Attach a facility to logger instance. procedure Attach_Default_Facility (Logger : in out Instance); -- Attach default facility with name Default_Facility_Name to logger -- instance. If the default facility is already attached do nothing. procedure Detach_Facility (Logger : in out Instance; Name : String); -- Detach a facility with name 'Name' from logger instance. If the facility -- is not found a Facility_Not_Found exception is raised. procedure Detach_Default_Facility (Logger : in out Instance); -- Detach default facility with name Default_Facility_Name from logger -- instance. If the default facility is not attached do nothing. function Facility_Count (Logger : Instance) return Natural; -- Return number of attached facilites. procedure Update (Logger : in out Instance; Name : String; Process : Tasked_Logger.Facility_Update_Handle); -- Update a specific Facility identified by 'Name'. Call the 'Process' -- procedure to perform the update operation. procedure Iterate (Logger : in out Instance; Process : Tasked_Logger.Facility_Update_Handle); -- Call 'Process' for all attached facilities. procedure Attach_Transform (Logger : in out Instance; Transform : Transforms.Handle); -- Attach a transform to logger instance. procedure Detach_Transform (Logger : in out Instance; Name : String); -- Detach a transform with name 'Name' from logger instance. If the -- transform is not found a Transform_Not_Found exception is raised. function Transform_Count (Logger : Instance) return Natural; -- Return number of attached transforms. procedure Clear (Logger : in out Instance); -- Clear logger instance. Detach and teardown all attached facilities and -- transforms. procedure Log_Message (Logger : in out Instance; Level : Log_Level; Msg : String; Source : String := ""); -- Log the given message asynchronously. The message is put into a log -- request queue which is continuously consumed by a logging task. -- -- This procedure is *safe* to call from protected actions (e.g. from an -- entry call statement or rendezvous). function Get_Queue_Length (Logger : Instance) return Natural; -- Returns the number of currently queued log messages. procedure Shutdown (Logger : in out Instance; Flush : Boolean := True); -- Shutdown the active logger. This procedure must be called in order for -- the logger task to be terminated properly. If 'Flush' is set to True the -- procedure will wait for all queued messages to be logged. function Is_Terminated (Logger : Instance) return Boolean; -- Returns True if active logger shutdown sequence is complete. procedure All_Done (Logger : in out Instance); -- This procedure blocks until all queued logging requests have been -- consumed. procedure Set_Except_Handler (Logger : Instance; Proc : Exceptions.Exception_Handler); -- Set custom exception handler procedure. type Shutdown_Helper (Logger : not null access Instance) is private; -- This helper will call Shutdown on the logger given as discriminant when -- it goes out of scope. This relieves the user from having to excplicitly -- call shutdown on an instance of Alog active logger when wanting to -- terminate. Users must make sure to declare any shutdown helper in a -- smaller scope than the active logger on which the helper supposed to -- work. private task type Logging_Task (Parent : not null access Instance); -- This task takes logging requests from the parent's message queue and -- logs them using the parent's backend logger. protected type Trigger_Type is procedure Shutdown; entry Stop; private Shutdown_Requested : Boolean := False; end Trigger_Type; -- This trigger is used to terminate the logger task by means of ATC. type Instance (Init : Boolean) is tagged limited record Logger_Task : Logging_Task (Parent => Instance'Access); Backend : Tasked_Logger.Instance (Init); Message_Queue : Protected_Containers.Log_Request_List; Trigger : Trigger_Type; end record; type Shutdown_Helper (Logger : not null access Instance) is new Ada.Finalization.Controlled with null record; overriding procedure Finalize (Helper : in out Shutdown_Helper); -- Call shutdown on the active logger instance specified as discriminat. end Alog.Active_Logger; libalog-0.5.0/src/alog-controlled_map.adb000066400000000000000000000076261241767602000203260ustar00rootroot00000000000000-- -- Copyright (c) 2009, -- Reto Buerki, Adrian-Ken Rueegsegger -- -- This file is part of Alog. -- -- Alog is free software; you can redistribute it and/or modify -- it under the terms of the GNU Lesser General Public License as published -- by the Free Software Foundation; either version 2.1 of the License, or -- (at your option) any later version. -- -- Alog is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public License -- along with Alog; if not, write to the Free Software -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, -- MA 02110-1301 USA -- with Ada.Unchecked_Deallocation; package body Alog.Controlled_Map is procedure Free is new Ada.Unchecked_Deallocation (Object => Element_Type, Name => Element_Handle); -- Free memory occupied by an element. ------------------------------------------------------------------------- procedure Clear (Container : in out Map) is procedure Do_Free (Position : MOEP.Cursor); -- Free the memory of an element. procedure Do_Free (Position : MOEP.Cursor) is Handle : Element_Handle := MOEP.Element (Position => Position); begin Free (X => Handle); end Do_Free; begin Container.Data.Iterate (Do_Free'Access); Container.Data.Clear; end Clear; ------------------------------------------------------------------------- function Contains (Container : Map; Key : Key_Type) return Boolean is begin return Container.Data.Contains (Key => Key); end Contains; ------------------------------------------------------------------------- procedure Delete (Container : in out Map; Key : Key_Type) is Handle : Element_Handle := Container.Data.Element (Key => Key); begin Container.Data.Delete (Key => Key); Free (Handle); end Delete; ------------------------------------------------------------------------- function Element (Container : Map; Key : Key_Type) return Element_Handle is begin return Container.Data.Element (Key => Key); end Element; ------------------------------------------------------------------------- procedure Finalize (Container : in out Map) is begin Container.Clear; end Finalize; ------------------------------------------------------------------------- procedure Insert (Container : in out Map; Key : Key_Type; New_Item : Element_Handle) is begin Container.Data.Insert (Key => Key, New_Item => New_Item); end Insert; ------------------------------------------------------------------------- function Is_Empty (Container : Map) return Boolean is begin return Container.Data.Is_Empty; end Is_Empty; ------------------------------------------------------------------------- procedure Iterate (Container : Map; Process : not null access procedure (Handle : Element_Handle)) is procedure Call_Process (Position : MOEP.Cursor); -- Call 'Process' for each element handle. procedure Call_Process (Position : MOEP.Cursor) is E_Handle : constant Element_Handle := MOEP.Element (Position => Position); begin Process (Handle => E_Handle); end Call_Process; begin Container.Data.Iterate (Process => Call_Process'Access); end Iterate; ------------------------------------------------------------------------- function Length (Container : Map) return Natural is begin return Natural (Container.Data.Length); end Length; end Alog.Controlled_Map; libalog-0.5.0/src/alog-controlled_map.ads000066400000000000000000000063501241767602000203400ustar00rootroot00000000000000-- -- Copyright (c) 2009, -- Reto Buerki, Adrian-Ken Rueegsegger -- -- This file is part of Alog. -- -- Alog is free software; you can redistribute it and/or modify -- it under the terms of the GNU Lesser General Public License as published -- by the Free Software Foundation; either version 2.1 of the License, or -- (at your option) any later version. -- -- Alog is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public License -- along with Alog; if not, write to the Free Software -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, -- MA 02110-1301 USA -- with Ada.Finalization; with Ada.Containers.Indefinite_Ordered_Maps; generic type Key_Type (<>) is private; type Element_Type (<>) is limited private; type Element_Handle is access Element_Type; with function "<" (Left, Right : Key_Type) return Boolean is <>; -- Controlled variant of a map. The memory of an element pointed to by a -- previously inserted handle is freed upon calling Delete, Clear or during -- finalization of the controlled map. Thus control over objects inserted into -- this map resides with the controlled map. package Alog.Controlled_Map is pragma Preelaborate; type Map is new Ada.Finalization.Limited_Controlled with private; -- A controlled map container. procedure Insert (Container : in out Map; Key : Key_Type; New_Item : Element_Handle); -- Insert a new element handle with 'Key' into the controlled map. function Element (Container : Map; Key : Key_Type) return Element_Handle; -- Return a handle to an element identified by 'Key'. procedure Delete (Container : in out Map; Key : Key_Type); -- Delete the element with key 'Key' from the map. Memory of the element is -- freed. function Contains (Container : Map; Key : Key_Type) return Boolean; -- Returns True if an element with key 'Key' is in the map. function Is_Empty (Container : Map) return Boolean; -- Returns True if the map is empty. procedure Clear (Container : in out Map); -- Remove all elements in the map. Memory of the elements is freed. function Length (Container : Map) return Natural; -- Return the current element count. procedure Iterate (Container : Map; Process : not null access procedure (Handle : Element_Handle)); -- Iterate over all elements in the map and call the 'Process' procedure -- for each handle. private overriding procedure Finalize (Container : in out Map); -- Clean up the the controlled map. This will Free all the memory occupied -- by the elements in the map. package Map_Of_Elements_Package is new Ada.Containers.Indefinite_Ordered_Maps (Key_Type => Key_Type, Element_Type => Element_Handle); package MOEP renames Map_Of_Elements_Package; type Map is new Ada.Finalization.Limited_Controlled with record Data : MOEP.Map; end record; end Alog.Controlled_Map; libalog-0.5.0/src/alog-exceptions.ads000066400000000000000000000024441241767602000175170ustar00rootroot00000000000000-- -- Copyright (c) 2011, -- Reto Buerki, Adrian-Ken Rueegsegger -- -- This file is part of Alog. -- -- Alog is free software; you can redistribute it and/or modify -- it under the terms of the GNU Lesser General Public License as published -- by the Free Software Foundation; either version 2.1 of the License, or -- (at your option) any later version. -- -- Alog is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public License -- along with Alog; if not, write to the Free Software -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, -- MA 02110-1301 USA -- with Ada.Exceptions; with Ada.Task_Identification; -- Alog exception package. Contains type definitions for Alog specific -- exception handling. package Alog.Exceptions is type Exception_Handler is not null access procedure (Except : Ada.Exceptions.Exception_Occurrence; Caller : Ada.Task_Identification.Task_Id); -- Exception handler callback procedure. Used to register custom callback -- procedures in active and tasked loggers. end Alog.Exceptions; libalog-0.5.0/src/alog-facilities-file_descriptor.adb000066400000000000000000000075471241767602000226150ustar00rootroot00000000000000-- -- Copyright (c) 2008-2009, -- Reto Buerki, Adrian-Ken Rueegsegger -- -- This file is part of Alog. -- -- Alog is free software; you can redistribute it and/or modify -- it under the terms of the GNU Lesser General Public License as published -- by the Free Software Foundation; either version 2.1 of the License, or -- (at your option) any later version. -- -- Alog is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public License -- along with Alog; if not, write to the Free Software -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, -- MA 02110-1301 USA -- with Ada.Directories; with Ada.Exceptions; package body Alog.Facilities.File_Descriptor is ------------------------------------------------------------------------- procedure Close_Logfile (Facility : in out Instance; Remove : Boolean := False) is use Ada.Text_IO; begin if Facility.Log_File_Ptr /= Standard_Output and Is_Open (File => Facility.Log_File) then if Remove then -- Close and delete. Delete (File => Facility.Log_File); else -- Close only. Close (File => Facility.Log_File); end if; end if; end Close_Logfile; ------------------------------------------------------------------------- function Get_Logfile (Facility : Instance) return Ada.Text_IO.File_Access is begin return Facility.Log_File_Ptr; end Get_Logfile; ------------------------------------------------------------------------- procedure Set_Logfile (Facility : in out Instance; Path : String; Append : Boolean := True) is begin if not Ada.Directories.Exists (Name => Path) then Ada.Text_IO.Create (File => Facility.Log_File, Mode => Ada.Text_IO.Out_File, Name => Path); else declare File_Mode : Ada.Text_IO.File_Mode := Ada.Text_IO.Append_File; begin if not Append then File_Mode := Ada.Text_IO.Out_File; end if; Ada.Text_IO.Open (File => Facility.Log_File, Name => Path, Mode => File_Mode); end; end if; -- Set logfile name and pointer to newly created file. Facility.Log_File_Name := To_Bounded_String (Path); -- Unchecked_Access is needed here since we use a pointer which is -- defined externaly in the Text_IO library. Facility.Log_File_Ptr := Facility.Log_File'Unchecked_Access; exception when E : others => raise Open_File_Error with "Unable to open logfile '" & Path & "': " & Ada.Exceptions.Exception_Message (X => E); end Set_Logfile; ------------------------------------------------------------------------- procedure Teardown (Facility : in out Instance) is begin Facility.Close_Logfile; end Teardown; ------------------------------------------------------------------------- procedure Write (Facility : Instance; Level : Log_Level := Info; Msg : String) is pragma Unreferenced (Level); use type Ada.Text_IO.File_Access; begin if Facility.Log_File_Ptr = Ada.Text_IO.Standard_Output then Ada.Text_IO.Put_Line (Item => Msg); Ada.Text_IO.Flush; else Ada.Text_IO.Put_Line (File => Facility.Log_File_Ptr.all, Item => Msg); Ada.Text_IO.Flush (File => Facility.Log_File_Ptr.all); end if; end Write; end Alog.Facilities.File_Descriptor; libalog-0.5.0/src/alog-facilities-file_descriptor.ads000066400000000000000000000051131241767602000226210ustar00rootroot00000000000000-- -- Copyright (c) 2008-2009, -- Reto Buerki, Adrian-Ken Rueegsegger -- -- This file is part of Alog. -- -- Alog is free software; you can redistribute it and/or modify -- it under the terms of the GNU Lesser General Public License as published -- by the Free Software Foundation; either version 2.1 of the License, or -- (at your option) any later version. -- -- Alog is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public License -- along with Alog; if not, write to the Free Software -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, -- MA 02110-1301 USA -- with Ada.Text_IO; -- File_Descriptor facility. Used to log to a console or file. If no file is -- specified by a Set_Logfile()-call, console logging is used. package Alog.Facilities.File_Descriptor is type Instance is new Alog.Facilities.Instance with private; -- File Descriptor based logging facility. type Handle is access all Instance; overriding procedure Teardown (Facility : in out Instance); -- Implementation of Teardown-procedure. procedure Set_Logfile (Facility : in out Instance; Path : String; Append : Boolean := True); -- Set logfile to use. If not set, standard output is used for logging. -- Set Append to False if an existing logfile should be overwritten. function Get_Logfile (Facility : Instance) return Ada.Text_IO.File_Access; -- Get currently used logfile. procedure Close_Logfile (Facility : in out Instance; Remove : Boolean := False); -- Close opened logfile. Open_File_Error : exception; -- This exception is raised if an error occurs while trying to open a -- logfile. private overriding procedure Write (Facility : Instance; Level : Log_Level := Info; Msg : String); -- Implementation of the Write procedure for FD. type Instance is new Alog.Facilities.Instance with record Log_File : aliased Ada.Text_IO.File_Type; -- Logfile used for file based logging. Log_File_Ptr : Ada.Text_IO.File_Access := Ada.Text_IO.Standard_Output; -- Reference to actual log file. Default is Standard_Output. Log_File_Name : BS_Path.Bounded_String := To_Bounded_String ("none"); -- File name of log file. end record; end Alog.Facilities.File_Descriptor; libalog-0.5.0/src/alog-facilities-syslog.adb000066400000000000000000000060631241767602000207500ustar00rootroot00000000000000-- -- Copyright (c) 2008-2011, -- Reto Buerki, Adrian-Ken Rueegsegger -- -- This file is part of Alog. -- -- Alog is free software; you can redistribute it and/or modify -- it under the terms of the GNU Lesser General Public License as published -- by the Free Software Foundation; either version 2.1 of the License, or -- (at your option) any later version. -- -- Alog is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public License -- along with Alog; if not, write to the Free Software -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, -- MA 02110-1301 USA -- with Interfaces.C.Strings; package body Alog.Facilities.Syslog is package C renames Interfaces.C; type L_Type is mod 2 ** 3; for L_Type'Size use 3; type F_Type is mod 2 ** 8; for F_Type'Size use 8; Level_Map : constant array (Log_Level) of L_Type := (Debug => 7, Info => 6, Notice => 5, Warning => 4, Error => 3, Critical => 2, Alert => 1, Emergency => 0); Facility_Map : constant array (Syslog_Origin) of F_Type := (LOG_KERN => 0, LOG_USER => 8, LOG_MAIL => 16, LOG_DAEMON => 24, LOG_AUTH => 32, LOG_SYSLOG => 40, LOG_LPR => 48, LOG_NEWS => 56, LOG_UUCP => 64, LOG_CRON => 72, LOG_AUTHPRIV => 80, LOG_FTP => 88, LOG_LOCAL0 => 128, LOG_LOCAL1 => 136, LOG_LOCAL2 => 144, LOG_LOCAL3 => 152, LOG_LOCAL4 => 160, LOG_LOCAL5 => 168, LOG_LOCAL6 => 176, LOG_LOCAL7 => 184); ------------------------------------------------------------------------- function Get_Origin (Facility : Instance) return Syslog_Origin is begin return Facility.Origin; end Get_Origin; ------------------------------------------------------------------------- procedure Set_Origin (Facility : in out Instance; Value : Syslog_Origin) is begin Facility.Origin := Value; end Set_Origin; ------------------------------------------------------------------------- procedure Write (Facility : Instance; Level : Log_Level := Info; Msg : String) is use type C.int; procedure Syslog_Wrapper (Prio : C.int; Msg : C.Strings.chars_ptr); pragma Import (C, Syslog_Wrapper, "syslog_wrapper"); C_Msg : C.Strings.chars_ptr := C.Strings.New_String (Str => Msg); C_Prio : constant C.int := C.int (Level_Map (Level)) + C.int (Facility_Map (Facility.Origin)); begin Syslog_Wrapper (Prio => C_Prio, Msg => C_Msg); C.Strings.Free (C_Msg); end Write; end Alog.Facilities.Syslog; libalog-0.5.0/src/alog-facilities-syslog.ads000066400000000000000000000041051241767602000207640ustar00rootroot00000000000000-- -- Copyright (c) 2008-2011, -- Reto Buerki, Adrian-Ken Rueegsegger -- -- This file is part of Alog. -- -- Alog is free software; you can redistribute it and/or modify -- it under the terms of the GNU Lesser General Public License as published -- by the Free Software Foundation; either version 2.1 of the License, or -- (at your option) any later version. -- -- Alog is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public License -- along with Alog; if not, write to the Free Software -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, -- MA 02110-1301 USA -- Syslog facility: Used to log to systems syslog. package Alog.Facilities.Syslog is type Instance is new Alog.Facilities.Instance with private; -- Syslog based logging facility. type Handle is access all Instance; type Syslog_Origin is (LOG_AUTH, LOG_AUTHPRIV, LOG_CRON, LOG_DAEMON, LOG_FTP, LOG_KERN, LOG_LOCAL0, LOG_LOCAL1, LOG_LOCAL2, LOG_LOCAL3, LOG_LOCAL4, LOG_LOCAL5, LOG_LOCAL6, LOG_LOCAL7, LOG_LPR, LOG_MAIL, LOG_NEWS, LOG_SYSLOG, LOG_USER, LOG_UUCP); -- Syslog facilties. Specifies what type of program is logging the message. procedure Set_Origin (Facility : in out Instance; Value : Syslog_Origin); -- Set origin of syslog message. function Get_Origin (Facility : Instance) return Syslog_Origin; -- Return currently set syslog origin of given facility. private overriding procedure Write (Facility : Instance; Level : Log_Level := Info; Msg : String); -- Implementation of the Write procedure for syslog. type Instance is new Alog.Facilities.Instance with record Origin : Syslog_Origin := LOG_USER; end record; end Alog.Facilities.Syslog; libalog-0.5.0/src/alog-facilities.adb000066400000000000000000000150511241767602000174270ustar00rootroot00000000000000-- -- Copyright (c) 2008-2012, -- Reto Buerki, Adrian-Ken Rueegsegger -- -- This file is part of Alog. -- -- Alog is free software; you can redistribute it and/or modify -- it under the terms of the GNU Lesser General Public License as published -- by the Free Software Foundation; either version 2.1 of the License, or -- (at your option) any later version. -- -- Alog is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public License -- along with Alog; if not, write to the Free Software -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, -- MA 02110-1301 USA -- with Ada.Calendar.Time_Zones; with GNAT.Calendar.Time_IO; with Alog.Policy_DB; package body Alog.Facilities is ------------------------------------------------------------------------- function "=" (Left : Handle; Right : Handle) return Boolean is begin return Left.Get_Name = Right.Get_Name; end "="; ------------------------------------------------------------------------- function Get_Name (Facility : Class) return String is begin return To_String (Facility.Name); end Get_Name; ------------------------------------------------------------------------- function Get_Timestamp (Facility : Class; Time : Ada.Calendar.Time := Ada.Calendar.Clock) return String is use GNAT.Calendar.Time_IO; begin if Facility.Is_UTC_Timestamp then declare use type Ada.Calendar.Time; use Ada.Calendar.Time_Zones; UTC_Offset : constant Time_Offset := UTC_Time_Offset (Time); UTC_Timestamp : constant String := Image (Date => Time - Duration (UTC_Offset) * 60, Picture => Picture_String (To_String (Facility.Timestamp_Format))); begin return UTC_Timestamp; end; else declare Timestamp : constant String := Image (Date => Time, Picture => Picture_String (To_String (Facility.Timestamp_Format))); begin return Timestamp; end; end if; end Get_Timestamp; ------------------------------------------------------------------------- function Is_UTC_Timestamp (Facility : Class) return Boolean is begin return Facility.UTC_Timestamp; end Is_UTC_Timestamp; ------------------------------------------------------------------------- function Is_Write_Loglevel (Facility : Class) return Boolean is begin return Facility.Write_Loglevel; end Is_Write_Loglevel; ------------------------------------------------------------------------- function Is_Write_Source (Facility : Class) return Boolean is begin return Facility.Write_Source; end Is_Write_Source; ------------------------------------------------------------------------- function Is_Write_Timestamp (Facility : Class) return Boolean is begin return Facility.Write_Timestamp; end Is_Write_Timestamp; ------------------------------------------------------------------------- procedure Process (Facility : Class; Request : Log_Request.Instance) is Message : Unbounded_String; Level : constant Log_Level := Request.Get_Log_Level; Msg : constant String := Request.Get_Message; Source : constant String := Request.Get_Source; begin if Policy_DB.Accept_Dst (Identifier => Facility.Get_Name, Level => Level) then if Facility.Is_Write_Timestamp then Append (Source => Message, New_Item => Facility.Get_Timestamp & " "); end if; if Facility.Is_Write_Loglevel then Append (Source => Message, New_Item => "[" & Log_Level'Image (Level) (1 .. 4) & "] "); end if; if Source'Length > 0 and then Facility.Is_Write_Source then Append (Source => Message, New_Item => Source & ": "); end if; Append (Source => Message, New_Item => Msg); Facility.Write (Level => Level, Msg => To_String (Message)); end if; end Process; ------------------------------------------------------------------------- procedure Set_Name (Facility : in out Class; Name : String) is begin Facility.Name := To_Unbounded_String (Name); end Set_Name; ------------------------------------------------------------------------- procedure Set_Timestamp_Format (Facility : in out Class; Format : String) is Now : constant Ada.Calendar.Time := Ada.Calendar.Clock; begin Validate_Format : declare Image : constant String := GNAT.Calendar.Time_IO.Image (Date => Now, Picture => GNAT.Calendar.Time_IO.Picture_String (Format)); pragma Unreferenced (Image); begin Facility.Timestamp_Format := To_Unbounded_String (Format); end Validate_Format; exception when GNAT.Calendar.Time_IO.Picture_Error => raise Invalid_Timestamp_Format with "Given timestamp format '" & Format & "' is invalid"; end Set_Timestamp_Format; ------------------------------------------------------------------------- procedure Toggle_UTC_Timestamp (Facility : in out Class; State : Boolean) is begin Facility.UTC_Timestamp := State; end Toggle_UTC_Timestamp; ------------------------------------------------------------------------- procedure Toggle_Write_Loglevel (Facility : in out Class; State : Boolean) is begin Facility.Write_Loglevel := State; end Toggle_Write_Loglevel; ------------------------------------------------------------------------- procedure Toggle_Write_Source (Facility : in out Class; State : Boolean) is begin Facility.Write_Source := State; end Toggle_Write_Source; ------------------------------------------------------------------------- procedure Toggle_Write_Timestamp (Facility : in out Class; State : Boolean) is begin Facility.Write_Timestamp := State; end Toggle_Write_Timestamp; end Alog.Facilities; libalog-0.5.0/src/alog-facilities.ads000066400000000000000000000130541241767602000174510ustar00rootroot00000000000000-- -- Copyright (c) 2008-2012, -- Reto Buerki, Adrian-Ken Rueegsegger -- -- This file is part of Alog. -- -- Alog is free software; you can redistribute it and/or modify -- it under the terms of the GNU Lesser General Public License as published -- by the Free Software Foundation; either version 2.1 of the License, or -- (at your option) any later version. -- -- Alog is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public License -- along with Alog; if not, write to the Free Software -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, -- MA 02110-1301 USA -- with Ada.Strings.Bounded; with Ada.Strings.Unbounded; with Ada.Command_Line; with Ada.Calendar; with Alog.Log_Request; -- Alog facilities package. Provides common data and methods used by all -- facilities. package Alog.Facilities is use Ada.Strings.Bounded; use Ada.Strings.Unbounded; type Instance is abstract tagged limited private; -- Abstract type facility instance. All facilities in the Alog framework -- must implement this type. subtype Class is Instance'Class; type Handle is access all Class; function "=" (Left : Handle; Right : Handle) return Boolean; -- Equal function. procedure Set_Name (Facility : in out Class; Name : String); -- Set facility name. function Get_Name (Facility : Class) return String; -- Get facility name. function Get_Timestamp (Facility : Class; Time : Ada.Calendar.Time := Ada.Calendar.Clock) return String; -- Creates a timestamp and returns it as String. If no Time is given, the -- current time is used. procedure Process (Facility : Class; Request : Log_Request.Instance); -- Process a log request. procedure Write (Facility : Instance; Level : Log_Level := Info; Msg : String) is abstract; -- Write message with specified log level. This procedure must be -- implemented by all facilities. procedure Toggle_Write_Timestamp (Facility : in out Class; State : Boolean); -- Enable/disable whether a timestamp is written for log messages. procedure Toggle_UTC_Timestamp (Facility : in out Class; State : Boolean); -- Enable/disable UTC timestamps for log messages. function Is_Write_Timestamp (Facility : Class) return Boolean; -- Returns the current value of Write_Timestamp. function Is_UTC_Timestamp (Facility : Class) return Boolean; -- Returns True if the timestamp of the facility is written in UTC time. procedure Set_Timestamp_Format (Facility : in out Class; Format : String); -- Set timestamp format. The format follows the GNU Date specification with -- some GNAT specific extensions. See the GNAT.Calendar.Time_IO specs for -- details about the accepted directives. The procedure raises an -- Invalid_Timestamp_Format exception if the given format is incorrect. -- If no specific format is set, '%b %d %Y %T' is used as default. procedure Toggle_Write_Loglevel (Facility : in out Class; State : Boolean); -- Enable/disable whether the loglevel is written for log messages. function Is_Write_Loglevel (Facility : Class) return Boolean; -- Returns the current value of Write_Loglevel. procedure Toggle_Write_Source (Facility : in out Class; State : Boolean); -- Enable/disable whether the source of the message is logged. function Is_Write_Source (Facility : Class) return Boolean; -- Returns True if writing of log message sources is enabled. procedure Setup (Facility : in out Instance) is null; -- Each facility must provide a Setup-procedure. These procedures are -- called by Logger instances when attaching Facilities. All needed -- operations prior to writing log messages should be done here. procedure Teardown (Facility : in out Instance) is null; -- Each facility must provide a Teardown-procedure. These procedures are -- called by Logger instances when detaching Facilities or when the logger -- object gets out of scope. package BS_Path is new Generic_Bounded_Length (Max_Path_Length); use BS_Path; -- Bounded string with length Max_Path_Length. Used in methods which -- involve filesystem operations. Invalid_Timestamp_Format : exception; private type Instance is abstract tagged limited record Name : Unbounded_String := To_Unbounded_String (Ada.Command_Line.Command_Name); -- Facility Name. Defaults to command-name (first argument). If multiple -- facilities are used, names must be set differently. Timestamp_Format : Unbounded_String := To_Unbounded_String ("%b %d %Y %T"); -- Default timestamp format to use in this facility. Write_Timestamp : Boolean := True; -- If True, a timestamp is written with the log message. UTC_Timestamp : Boolean := False; -- If True, the timestamp is written in UTC time. -- (log message timestamps are written timezone-dependent). Write_Loglevel : Boolean := False; -- If True, the loglevel associated with the log message is written. Write_Source : Boolean := True; -- If True, the source of a log message is prepended to the message. end record; end Alog.Facilities; libalog-0.5.0/src/alog-helpers.adb000066400000000000000000000121121241767602000167500ustar00rootroot00000000000000-- -- Copyright (c) 2008-2009, -- Reto Buerki, Adrian-Ken Rueegsegger -- -- This file is part of Alog. -- -- Alog is free software; you can redistribute it and/or modify -- it under the terms of the GNU Lesser General Public License as published -- by the Free Software Foundation; either version 2.1 of the License, or -- (at your option) any later version. -- -- Alog is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public License -- along with Alog; if not, write to the Free Software -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, -- MA 02110-1301 USA -- with Ada.Text_IO; with Ada.Strings.Fixed; package body Alog.Helpers is ------------------------------------------------------------------------- function Assert_Files_Equal (Filename1 : String; Filename2 : String) return Boolean is File1 : D_IO.File_Type; File2 : D_IO.File_Type; Char1, Char2 : My_Rec; Result : Boolean := True; begin -- Open both files. Open (File => File1, Mode => In_File, Name => Filename1); Open (File => File2, Mode => In_File, Name => Filename2); -- Check length of files first. if Size (File1) /= Size (File2) then Close (File => File1); Close (File => File2); return False; end if; while not End_Of_File (File1) loop -- Read one byte from both files. Read (File => File1, Item => Char1); Read (File => File2, Item => Char2); -- Compare it. if Char1 /= Char2 then Result := False; end if; end loop; -- Close them files again. Close (File => File1); Close (File => File2); return Result; end Assert_Files_Equal; ------------------------------------------------------------------------- procedure Read_Loglevels (Filename : String; Default_Level : in out Log_Level; Identifiers : out Maps.Wildcard_Level_Map) is Conf_File : Ada.Text_IO.File_Type; Line_Count : Natural := 0; Line : String (1 .. 1_024); Last : Integer; begin Ada.Text_IO.Open (File => Conf_File, Mode => Ada.Text_IO.In_File, Name => Filename); while not Ada.Text_IO.End_Of_File (File => Conf_File) loop Ada.Text_IO.Get_Line (File => Conf_File, Item => Line, Last => Last); Line_Count := Line_Count + 1; if Last - Line'First >= 0 then declare Trimmed : constant String := Ada.Strings.Fixed.Trim (Source => Line (Line'First .. Last), Side => Ada.Strings.Both); Eq : Natural; begin if Trimmed'Length /= 0 and then Trimmed (Trimmed'First) /= '#' then Eq := Ada.Strings.Fixed.Index (Source => Trimmed, Pattern => "="); if Eq not in Trimmed'First + 1 .. Trimmed'Last then Ada.Text_IO.Close (File => Conf_File); raise Invalid_Config with "Syntax error in file " & Filename & " on line" & Line_Count'Img & ": no assignment operator"; end if; -- Line seems valid declare Key : constant String := Ada.Strings.Fixed.Trim (Source => Trimmed (Trimmed'First .. Eq - 1), Side => Ada.Strings.Both); Value : constant String := Ada.Strings.Fixed.Trim (Source => Trimmed (Eq + 1 .. Trimmed'Last), Side => Ada.Strings.Both); Loglevel : Log_Level; begin begin Loglevel := Log_Level'Value (Value); exception when others => Ada.Text_IO.Close (File => Conf_File); raise Invalid_Config with "Syntax error in file " & Filename & " on line" & Line_Count'Img & ": invalid loglevel '" & Value & "'"; end; if Key = "Default" or Key = "default" then Default_Level := Loglevel; else Identifiers.Insert (Key => Key, Item => Loglevel); end if; end; end if; end; end if; end loop; Ada.Text_IO.Close (File => Conf_File); end Read_Loglevels; end Alog.Helpers; libalog-0.5.0/src/alog-helpers.ads000066400000000000000000000040141241767602000167730ustar00rootroot00000000000000-- -- Copyright (c) 2008-2009, -- Reto Buerki, Adrian-Ken Rueegsegger -- -- This file is part of Alog. -- -- Alog is free software; you can redistribute it and/or modify -- it under the terms of the GNU Lesser General Public License as published -- by the Free Software Foundation; either version 2.1 of the License, or -- (at your option) any later version. -- -- Alog is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public License -- along with Alog; if not, write to the Free Software -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, -- MA 02110-1301 USA -- with Ada.Direct_IO; with Alog.Maps; -- Alog helper functions/procedures. package Alog.Helpers is function Assert_Files_Equal (Filename1 : String; Filename2 : String) return Boolean; -- Compare two files byte-wise. Returns True if both files are equal. -- The two files are closed but not removed after comparison. procedure Read_Loglevels (Filename : String; Default_Level : in out Log_Level; Identifiers : out Maps.Wildcard_Level_Map); -- Read default loglevels and (optional) identifier based loglevels from -- file given by filename. The format is as follows: -- -- # This is a comment (ignored) -- -- # Default loglevel -- Default = Info -- -- # Identifier-specific loglevels -- Foo.* = Debug -- Foo.Bar = Info -- -- If no default loglevel setting is found in the file, the loglevel passed -- as Default_Level parameter is returned unchanged. Invalid_Config : exception; -- Exception is raised if a loglevel config file is invalid. private type My_Rec is record Char : Character; end record; package D_IO is new Ada.Direct_IO (My_Rec); use D_IO; end Alog.Helpers; libalog-0.5.0/src/alog-log_request.adb000066400000000000000000000043231241767602000176440ustar00rootroot00000000000000-- -- Copyright (c) 2009, -- Reto Buerki, Adrian-Ken Rueegsegger -- -- This file is part of Alog. -- -- Alog is free software; you can redistribute it and/or modify -- it under the terms of the GNU Lesser General Public License as published -- by the Free Software Foundation; either version 2.1 of the License, or -- (at your option) any later version. -- -- Alog is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public License -- along with Alog; if not, write to the Free Software -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, -- MA 02110-1301 USA -- package body Alog.Log_Request is use Ada.Strings.Unbounded; ------------------------------------------------------------------------- function Create (ID : Task_Id := Current_Task; Source : String := ""; Level : Log_Level := Debug; Message : String) return Instance is begin return Instance'(Caller_ID => ID, Source => To_Unbounded_String (Source), Level => Level, Message => To_Unbounded_String (Message)); end Create; ------------------------------------------------------------------------- function Get_Caller_ID (Request : Instance) return Task_Id is begin return Request.Caller_ID; end Get_Caller_ID; ------------------------------------------------------------------------- function Get_Log_Level (Request : Instance) return Log_Level is begin return Request.Level; end Get_Log_Level; ------------------------------------------------------------------------- function Get_Message (Request : Instance) return String is begin return To_String (Request.Message); end Get_Message; ------------------------------------------------------------------------- function Get_Source (Request : Instance) return String is begin return To_String (Request.Source); end Get_Source; end Alog.Log_Request; libalog-0.5.0/src/alog-log_request.ads000066400000000000000000000042711241767602000176670ustar00rootroot00000000000000-- -- Copyright (c) 2009, -- Reto Buerki, Adrian-Ken Rueegsegger -- -- This file is part of Alog. -- -- Alog is free software; you can redistribute it and/or modify -- it under the terms of the GNU Lesser General Public License as published -- by the Free Software Foundation; either version 2.1 of the License, or -- (at your option) any later version. -- -- Alog is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public License -- along with Alog; if not, write to the Free Software -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, -- MA 02110-1301 USA -- with Ada.Task_Identification; with Ada.Strings.Unbounded; -- Log request type. Log request objects are used for asynchronous logging and -- hold all relevant information of a log request. package Alog.Log_Request is use Ada.Task_Identification; type Instance is tagged private; -- A log request contains all related information to log asynchronously -- (Caller identification, loglevel and message). function Create (ID : Task_Id := Current_Task; Source : String := ""; Level : Log_Level := Debug; Message : String) return Instance; -- Create a log request object from the specified parameters. function Get_Caller_ID (Request : Instance) return Task_Id; -- Return the caller ID of the request object. function Get_Source (Request : Instance) return String; -- Return the source of the request object. function Get_Log_Level (Request : Instance) return Log_Level; -- Return the loglevel of the request object. function Get_Message (Request : Instance) return String; -- Return the log message of the request object. private type Instance is tagged record Caller_ID : Task_Id := Null_Task_Id; Source : Ada.Strings.Unbounded.Unbounded_String; Level : Log_Level := Info; Message : Ada.Strings.Unbounded.Unbounded_String; end record; end Alog.Log_Request; libalog-0.5.0/src/alog-logger.adb000066400000000000000000000215271241767602000165770ustar00rootroot00000000000000-- -- Copyright (c) 2008-2012, -- Reto Buerki, Adrian-Ken Rueegsegger -- -- This file is part of Alog. -- -- Alog is free software; you can redistribute it and/or modify -- it under the terms of the GNU Lesser General Public License as published -- by the Free Software Foundation; either version 2.1 of the License, or -- (at your option) any later version. -- -- Alog is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public License -- along with Alog; if not, write to the Free Software -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, -- MA 02110-1301 USA -- with Alog.Log_Request; with Alog.Facilities.File_Descriptor; package body Alog.Logger is ------------------------------------------------------------------------- procedure Attach_Default_Facility (Logger : in out Instance) is begin if not Logger.Facilities.Contains (Key => To_Unbounded_String (Default_Facility_Name)) then declare Default_Handle : Facilities.File_Descriptor.Handle; begin Default_Handle := new Facilities.File_Descriptor.Instance; Default_Handle.Set_Name (Name => Default_Facility_Name); Logger.Attach_Facility (Facility => Facilities.Handle (Default_Handle)); end; end if; end Attach_Default_Facility; ------------------------------------------------------------------------- procedure Attach_Facility (Logger : in out Instance; Facility : Facilities.Handle) is F_Name : constant Unbounded_String := To_Unbounded_String (Facility.Get_Name); begin if Logger.Facilities.Contains (Key => F_Name) then raise Facility_Already_Present with "Facility '" & To_String (F_Name) & "' is already present."; end if; Logger.Facilities.Insert (Key => F_Name, New_Item => Facility); end Attach_Facility; ------------------------------------------------------------------------- procedure Attach_Transform (Logger : in out Instance; Transform : Transforms.Handle) is T_Name : constant Unbounded_String := To_Unbounded_String (Transform.Get_Name); begin if Logger.Transforms.Contains (Key => T_Name) then raise Transform_Already_Present with "Transform '" & To_String (T_Name) & "' is already present."; end if; Logger.Transforms.Insert (Key => T_Name, New_Item => Transform); end Attach_Transform; ------------------------------------------------------------------------- procedure Clear (L : in out Instance) is procedure Teardown_Facility (Handle : Facilities.Handle); -- Teardown a facility. procedure Teardown_Facility (Handle : Facilities.Handle) is begin Handle.Teardown; end Teardown_Facility; procedure Teardown_Transform (Handle : Transforms.Handle); -- Teardown a transform. procedure Teardown_Transform (Handle : Transforms.Handle) is begin Handle.Teardown; end Teardown_Transform; begin L.Facilities.Iterate (Process => Teardown_Facility'Access); L.Facilities.Clear; L.Transforms.Iterate (Process => Teardown_Transform'Access); L.Transforms.Clear; end Clear; ------------------------------------------------------------------------- procedure Detach_Default_Facility (Logger : in out Instance) is begin if Logger.Facilities.Contains (Key => To_Unbounded_String (Default_Facility_Name)) then Logger.Detach_Facility (Name => Default_Facility_Name); end if; end Detach_Default_Facility; ------------------------------------------------------------------------- procedure Detach_Facility (Logger : in out Instance; Name : String) is F_Name : constant Unbounded_String := To_Unbounded_String (Name); begin if not Logger.Facilities.Contains (Key => F_Name) then raise Facility_Not_Found with "Facility '" & Name & "' not found."; end if; Logger.Facilities.Delete (Key => F_Name); end Detach_Facility; ------------------------------------------------------------------------- procedure Detach_Transform (Logger : in out Instance; Name : String) is T_Name : constant Unbounded_String := To_Unbounded_String (Name); begin if not Logger.Transforms.Contains (Key => T_Name) then raise Transform_Not_Found with "Transform '" & Name & "' not found."; end if; Logger.Transforms.Delete (Key => T_Name); end Detach_Transform; ------------------------------------------------------------------------- function Facility_Count (Logger : Instance) return Natural is begin return Logger.Facilities.Length; end Facility_Count; ------------------------------------------------------------------------- procedure Finalize (Logger : in out Instance) is begin Logger.Clear; end Finalize; ------------------------------------------------------------------------- procedure Initialize (Logger : in out Instance) is begin if Logger.Init then Logger.Attach_Default_Facility; end if; end Initialize; ------------------------------------------------------------------------- procedure Iterate (Logger : Instance; Process : not null access procedure (Facility_Handle : Facilities.Handle)) is begin Logger.Facilities.Iterate (Process => Process); end Iterate; ------------------------------------------------------------------------- procedure Iterate (Logger : Instance; Process : not null access procedure (Transform_Handle : Transforms.Handle)) is begin Logger.Transforms.Iterate (Process => Process); end Iterate; ------------------------------------------------------------------------- procedure Log_Message (Logger : Instance; Level : Log_Level; Msg : String; Source : String := "") is Out_Msg : String := Msg; Prefix : Unbounded_String; procedure Do_Log (Facility_Handle : Facilities.Handle); -- Log message for each facility. procedure Do_Log (Facility_Handle : Facilities.Handle) is New_Request : constant Log_Request.Instance := Log_Request.Create (Source => Source, Level => Level, Message => To_String (Prefix) & Out_Msg); begin Facility_Handle.Process (Request => New_Request); end Do_Log; procedure Do_Transform (Transform_Handle : Transforms.Handle); -- Call 'Transform_Message' for each transform. procedure Do_Transform (Transform_Handle : Transforms.Handle) is begin Out_Msg := Transform_Handle.Transform_Message (Level => Level, Msg => Out_Msg); end Do_Transform; begin Logger.Iterate (Process => Do_Transform'Access); Logger.Iterate (Process => Do_Log'Access); end Log_Message; ------------------------------------------------------------------------- function Transform_Count (Logger : Instance) return Natural is begin return Logger.Transforms.Length; end Transform_Count; ------------------------------------------------------------------------- procedure Update (Logger : Instance; Name : String; Process : not null access procedure (Facility_Handle : Facilities.Handle)) is F_Name : constant Unbounded_String := To_Unbounded_String (Name); begin if not Logger.Facilities.Contains (Key => F_Name) then raise Facility_Not_Found with "Facility '" & Name & "' not found"; end if; declare Handle : constant Facilities.Handle := Logger.Facilities.Element (Key => F_Name); begin Process (Facility_Handle => Handle); end; end Update; ------------------------------------------------------------------------- procedure Update (Logger : Instance; Name : String; Process : not null access procedure (Transform_Handle : Transforms.Handle)) is T_Name : constant Unbounded_String := To_Unbounded_String (Name); begin if not Logger.Transforms.Contains (Key => T_Name) then raise Transform_Not_Found with "Transform '" & Name & "' not found"; end if; declare Handle : constant Transforms.Handle := Logger.Transforms.Element (Key => T_Name); begin Process (Transform_Handle => Handle); end; end Update; end Alog.Logger; libalog-0.5.0/src/alog-logger.ads000066400000000000000000000146011241767602000166130ustar00rootroot00000000000000-- -- Copyright (c) 2008-2012, -- Reto Buerki, Adrian-Ken Rueegsegger -- -- This file is part of Alog. -- -- Alog is free software; you can redistribute it and/or modify -- it under the terms of the GNU Lesser General Public License as published -- by the Free Software Foundation; either version 2.1 of the License, or -- (at your option) any later version. -- -- Alog is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public License -- along with Alog; if not, write to the Free Software -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, -- MA 02110-1301 USA -- with Ada.Finalization; with Ada.Unchecked_Deallocation; with Ada.Strings.Unbounded; with Alog.Facilities; with Alog.Transforms; with Alog.Controlled_Map; -- Logger instance. Facilities can be attached to a logger instance in order -- to log to different targets simultaneously. A logger provides different -- helper functions for logging facilities configuration. package Alog.Logger is type Instance (Init : Boolean) is tagged limited private; -- Logger instance. The Init discriminant defines whether or not a default -- 'stdout' (FD facility without logfile set) is attached automatically. --- Set Init to 'True' if you want to make sure minimal stdout logging is -- possible as soon as a new logger is instantiated. type Handle is access all Instance; -- Handle to logger type. procedure Attach_Facility (Logger : in out Instance; Facility : Facilities.Handle); -- Attach a facility to logger instance. procedure Attach_Default_Facility (Logger : in out Instance); -- Attach default facility with name Default_Facility_Name to logger -- instance. If the default facility is already attached do nothing. procedure Detach_Facility (Logger : in out Instance; Name : String); -- Detach a facility with name 'Name' from logger instance. If the facility -- is not found a Facility_Not_Found exception is raised. procedure Detach_Default_Facility (Logger : in out Instance); -- Detach default facility with name Default_Facility_Name from logger -- instance. If the default facility is not attached do nothing. function Facility_Count (Logger : Instance) return Natural; -- Return number of attached facilites. procedure Update (Logger : Instance; Name : String; Process : not null access procedure (Facility_Handle : Facilities.Handle)); -- Update a specific Facility identified by 'Name'. Call the 'Process' -- procedure to perform the update operation. procedure Iterate (Logger : Instance; Process : not null access procedure (Facility_Handle : Facilities.Handle)); -- Call 'Process' for all attached facilities. procedure Attach_Transform (Logger : in out Instance; Transform : Transforms.Handle); -- Attach a transform to logger instance. procedure Detach_Transform (Logger : in out Instance; Name : String); -- Detach a transform with name 'Name' from logger instance. If the -- transform is not found a Transform_Not_Found exception is raised. function Transform_Count (Logger : Instance) return Natural; -- Return number of attached transforms. procedure Update (Logger : Instance; Name : String; Process : not null access procedure (Transform_Handle : Transforms.Handle)); -- Update a specific Transform identified by 'Name'. Call the 'Process' -- procedure to perform the update operation. procedure Iterate (Logger : Instance; Process : not null access procedure (Transform_Handle : Transforms.Handle)); -- Call 'Process' for all attached transforms. procedure Clear (L : in out Instance); -- Clear logger instance. Detach and teardown all attached facilities and -- transforms. procedure Log_Message (Logger : Instance; Level : Log_Level; Msg : String; Source : String := ""); -- Log a message. The Write_Message() procedure of all attached facilities -- is called. Depending on the Log-Threshold set, the message is logged to -- different targets (depending on the facilites) automatically. -- -- Prior to actually processing the given log message the policy database -- is inquired if the log message with given source and level should be -- logged. procedure Free is new Ada.Unchecked_Deallocation (Object => Facilities.Class, Name => Facilities.Handle); -- Free memory allocated by a facility. procedure Free is new Ada.Unchecked_Deallocation (Object => Transforms.Class, Name => Transforms.Handle); -- Free memory allocated by a transform. Facility_Not_Found : exception; -- Will be raised if a requested facility is not found. Facility_Already_Present : exception; -- Will be raised if a facility is already present. Transform_Not_Found : exception; -- Will be raised if a requested transform is not found. Transform_Already_Present : exception; -- Will be raised if a facility is already present. . Default_Facility_Name : constant String := "__Default_Facility"; private use Ada.Strings.Unbounded; use Alog.Facilities; use Alog.Transforms; procedure Initialize (Logger : in out Instance); -- Initialize the logger instance. procedure Finalize (Logger : in out Instance); -- Finalize procedure used to cleanup. package Map_Of_Transforms_Package is new Alog.Controlled_Map (Key_Type => Unbounded_String, Element_Type => Transforms.Class, Element_Handle => Transforms.Handle); package MOTP renames Map_Of_Transforms_Package; package Map_Of_Facilities_Package is new Alog.Controlled_Map (Key_Type => Unbounded_String, Element_Type => Facilities.Class, Element_Handle => Facilities.Handle); package MOFP renames Map_Of_Facilities_Package; type Instance (Init : Boolean) is new Ada.Finalization.Limited_Controlled with record Facilities : MOFP.Map; -- Attached facilities. Transforms : MOTP.Map; -- Attached transforms. end record; end Alog.Logger; libalog-0.5.0/src/alog-maps.adb000066400000000000000000000071521241767602000162560ustar00rootroot00000000000000-- -- Copyright (c) 2009, -- Reto Buerki, Adrian-Ken Rueegsegger -- -- This file is part of Alog. -- -- Alog is free software; you can redistribute it and/or modify -- it under the terms of the GNU Lesser General Public License as published -- by the Free Software Foundation; either version 2.1 of the License, or -- (at your option) any later version. -- -- Alog is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public License -- along with Alog; if not, write to the Free Software -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, -- MA 02110-1301 USA -- with Ada.Strings.Fixed; package body Alog.Maps is ------------------------------------------------------------------------- procedure Clear (Map : in out Wildcard_Level_Map) is begin Map.Data.Clear; end Clear; ------------------------------------------------------------------------- function Element (Map : Wildcard_Level_Map; Key : String) return Log_Level is begin return Map.Data.Element (Key => To_Unbounded_String (Key)); end Element; ------------------------------------------------------------------------- function Element (Position : Cursor) return Log_Level is begin return MOLP.Element (Position => MOLP.Cursor (Position)); end Element; ------------------------------------------------------------------------- function Find (Map : Wildcard_Level_Map; Key : String) return Cursor is begin return Cursor (Map.Data.Find (Key => To_Unbounded_String (Key))); end Find; ------------------------------------------------------------------------- procedure Insert (Map : in out Wildcard_Level_Map; Key : String; Item : Log_Level) is Position : MOLP.Cursor; Insert_Ok : Boolean := False; begin Map.Data.Insert (Key => To_Unbounded_String (Key), New_Item => Item, Position => Position, Inserted => Insert_Ok); if not Insert_Ok then Map.Data.Replace_Element (Position => Position, New_Item => Item); end if; end Insert; ------------------------------------------------------------------------- function Length (Map : Wildcard_Level_Map) return Natural is begin return Natural (Map.Data.Length); end Length; ------------------------------------------------------------------------- function Lookup (Map : Wildcard_Level_Map; Key : String) return Cursor is Position : Cursor; begin -- Exact match Position := Map.Find (Key => Key); if Position /= No_Element then return Position; end if; Find_Closest_Match : declare Substr_Index : Integer := Key'Last; begin while Substr_Index > 0 loop Position := Map.Find (Key => Key (Key'First .. Substr_Index) & "." & Wildcard); if Position /= No_Element then return Position; end if; Substr_Index := Ada.Strings.Fixed.Index (Source => Key, Pattern => ".", From => Substr_Index, Going => Ada.Strings.Backward) - 1; end loop; end Find_Closest_Match; return No_Element; end Lookup; end Alog.Maps; libalog-0.5.0/src/alog-maps.ads000066400000000000000000000064411241767602000162770ustar00rootroot00000000000000-- -- Copyright (c) 2009, -- Reto Buerki, Adrian-Ken Rueegsegger -- -- This file is part of Alog. -- -- Alog is free software; you can redistribute it and/or modify -- it under the terms of the GNU Lesser General Public License as published -- by the Free Software Foundation; either version 2.1 of the License, or -- (at your option) any later version. -- -- Alog is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public License -- along with Alog; if not, write to the Free Software -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, -- MA 02110-1301 USA -- with Ada.Strings.Unbounded.Hash; with Ada.Containers.Hashed_Maps; -- Alog maps package. Provides map data types. package Alog.Maps is type Wildcard_Level_Map is tagged private; -- A map of loglevels with string as key type. type Cursor is private; -- Index for a map element. No_Element : constant Cursor; Wildcard : constant Character := '*'; -- Character used as wildcard indicator in lookups. function Element (Map : Wildcard_Level_Map; Key : String) return Log_Level; -- Returns the loglevel element for given key. function Element (Position : Cursor) return Log_Level; -- Returns the loglevel element at given position. function Find (Map : Wildcard_Level_Map; Key : String) return Cursor; -- Returns the position for an element with specified key. If no element is -- found No_Element is returned. function Lookup (Map : Wildcard_Level_Map; Key : String) return Cursor; -- Returns the position of the element with the closest match to given key. -- This function considers wildcards when searching for an element. -- -- Example: Key | Element -- ------------------- -- Foo.* | Debug -- Foo.Bar | Alert -- -- A lookup for "Foo.Foo" has no exact match. The next closest match is -- "Foo.*" which will return the Debug element. Looking for "Foo" will -- return Debug since it matches the wildcard "Foo.*". -- -- If no exact and wildcard match is found No_Element is returned. procedure Insert (Map : in out Wildcard_Level_Map; Key : String; Item : Log_Level); -- Insert given key/item pair into map. If given key is already present the -- associated item is replaced. procedure Clear (Map : in out Wildcard_Level_Map); -- Clears the wildcard map. function Length (Map : Wildcard_Level_Map) return Natural; -- Return the number of elements in the map. private use Ada.Strings.Unbounded; package Map_Of_Loglevels_Package is new Ada.Containers.Hashed_Maps (Key_Type => Unbounded_String, Element_Type => Log_Level, Hash => Hash, Equivalent_Keys => "="); package MOLP renames Map_Of_Loglevels_Package; type Wildcard_Level_Map is tagged record Data : MOLP.Map; end record; type Cursor is new MOLP.Cursor; No_Element : constant Cursor := Cursor (MOLP.No_Element); end Alog.Maps; libalog-0.5.0/src/alog-policy_db-types.adb000066400000000000000000000077331241767602000204310ustar00rootroot00000000000000-- -- Copyright (c) 2009, -- Reto Buerki, Adrian-Ken Rueegsegger -- -- This file is part of Alog. -- -- Alog is free software; you can redistribute it and/or modify -- it under the terms of the GNU Lesser General Public License as published -- by the Free Software Foundation; either version 2.1 of the License, or -- (at your option) any later version. -- -- Alog is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public License -- along with Alog; if not, write to the Free Software -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, -- MA 02110-1301 USA -- package body Alog.Policy_DB.Types is Current_Default_Loglevel : Log_Level := Alog_Default_Level; -- Current default loglevel. ------------------------------------------------------------------------- protected body Protected_Policy_DB is ------------------------------------------------------------------------- function Accept_Dst (Identifier : String; Level : Log_Level) return Boolean is use type Alog.Maps.Cursor; Position : Maps.Cursor; begin Position := Ident_Levels.Lookup (Key => Identifier); if Position /= Maps.No_Element then return Level >= Maps.Element (Position => Position); end if; return True; end Accept_Dst; ------------------------------------------------------------------------- function Accept_Src (Identifier : String := ""; Level : Log_Level) return Boolean is begin return Level >= Lookup (Identifier => Identifier); end Accept_Src; ------------------------------------------------------------------------- function Get_Default_Loglevel return Log_Level is begin return Current_Default_Loglevel; end Get_Default_Loglevel; ------------------------------------------------------------------------- function Get_Loglevel (Identifier : String) return Log_Level is begin return Ident_Levels.Element (Key => Identifier); exception when Constraint_Error => raise No_Ident_Loglevel with "No loglevel for identifier '" & Identifier & "'"; end Get_Loglevel; ------------------------------------------------------------------------- function Lookup (Identifier : String) return Log_Level is use type Alog.Maps.Cursor; Position : Maps.Cursor; begin Position := Ident_Levels.Lookup (Key => Identifier); if Position /= Maps.No_Element then return Maps.Element (Position => Position); end if; return Current_Default_Loglevel; end Lookup; ------------------------------------------------------------------------- procedure Reset is begin Current_Default_Loglevel := Alog_Default_Level; Ident_Levels.Clear; end Reset; ------------------------------------------------------------------------- procedure Set_Default_Loglevel (Level : Log_Level) is begin Current_Default_Loglevel := Level; end Set_Default_Loglevel; ------------------------------------------------------------------------- procedure Set_Loglevel (Identifier : String; Level : Log_Level) is begin Ident_Levels.Insert (Key => Identifier, Item => Level); end Set_Loglevel; ------------------------------------------------------------------------- procedure Set_Loglevel (Identifiers : Maps.Wildcard_Level_Map) is begin Ident_Levels := Identifiers; end Set_Loglevel; end Protected_Policy_DB; end Alog.Policy_DB.Types; libalog-0.5.0/src/alog-policy_db-types.ads000066400000000000000000000066061241767602000204500ustar00rootroot00000000000000-- -- Copyright (c) 2009, -- Reto Buerki, Adrian-Ken Rueegsegger -- -- This file is part of Alog. -- -- Alog is free software; you can redistribute it and/or modify -- it under the terms of the GNU Lesser General Public License as published -- by the Free Software Foundation; either version 2.1 of the License, or -- (at your option) any later version. -- -- Alog is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public License -- along with Alog; if not, write to the Free Software -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, -- MA 02110-1301 USA -- package Alog.Policy_DB.Types is protected type Protected_Policy_DB is procedure Set_Default_Loglevel (Level : Log_Level); -- Set given loglevel as default loglevel. function Get_Default_Loglevel return Log_Level; -- Return current default loglevel. procedure Set_Loglevel (Identifier : String; Level : Log_Level); -- Set given loglevel for specified identifier string. If the identifier -- is already present the loglevel is updated. Identifier strings are -- case-sensitive. -- -- Use wildcards to specify a loglevel for a range of identifiers. -- Identifier hierarchies are separated by dots, the wildcard is '*'. -- The following example sets a Debug loglevel for all log-identifiers -- in Foo.Bar (including Foo.Bar). -- -- Example: -- Foo.Bar.* = Debug -- -- Direct matches take precedence over wildcard matches. In the -- following example the loglevel for identifier 'Foo.Bar' is -- explicitly set to Info. -- -- Example: -- Foo.Bar = Info -- Foo.Bar.* = Debug procedure Set_Loglevel (Identifiers : Maps.Wildcard_Level_Map); -- Apply loglevels for identifiers stored in map. function Get_Loglevel (Identifier : String) return Log_Level; -- Return loglevel for given identifier string. Raises No_Ident_Loglevel -- exception if no entry for given identifier is found (exact match -- only, no wildcard lookup). function Lookup (Identifier : String) return Log_Level; -- Return loglevel for given identifier string. Returns the closest -- match, if no associated loglevel is found the default loglevel -- is returned. procedure Reset; -- Reset the logging policy database to the initial state. function Accept_Src (Identifier : String := ""; Level : Log_Level) return Boolean; -- Returns True if the given loglevel is accepted for a source -- identifier. If no identifier is given, the loglevel is verified -- against the default loglevel. function Accept_Dst (Identifier : String; Level : Log_Level) return Boolean; -- Returns True if the given loglevel is accepted for a destination -- identifier. If no match for the given identifier is found True is -- returned. private Ident_Levels : Maps.Wildcard_Level_Map; -- Identifier based loglevels. end Protected_Policy_DB; end Alog.Policy_DB.Types; libalog-0.5.0/src/alog-policy_db.adb000066400000000000000000000060231241767602000172560ustar00rootroot00000000000000-- -- Copyright (c) 2009, -- Reto Buerki, Adrian-Ken Rueegsegger -- -- This file is part of Alog. -- -- Alog is free software; you can redistribute it and/or modify -- it under the terms of the GNU Lesser General Public License as published -- by the Free Software Foundation; either version 2.1 of the License, or -- (at your option) any later version. -- -- Alog is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public License -- along with Alog; if not, write to the Free Software -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, -- MA 02110-1301 USA -- with Alog.Policy_DB.Types; package body Alog.Policy_DB is Instance : Types.Protected_Policy_DB; ------------------------------------------------------------------------- function Accept_Dst (Identifier : String; Level : Log_Level) return Boolean is begin return Instance.Accept_Dst (Identifier => Identifier, Level => Level); end Accept_Dst; ------------------------------------------------------------------------- function Accept_Src (Identifier : String := ""; Level : Log_Level) return Boolean is begin return Instance.Accept_Src (Identifier => Identifier, Level => Level); end Accept_Src; ------------------------------------------------------------------------- function Get_Default_Loglevel return Log_Level is begin return Instance.Get_Default_Loglevel; end Get_Default_Loglevel; ------------------------------------------------------------------------- function Get_Loglevel (Identifier : String) return Log_Level is begin return Instance.Get_Loglevel (Identifier => Identifier); end Get_Loglevel; ------------------------------------------------------------------------- function Lookup (Identifier : String) return Log_Level is begin return Instance.Lookup (Identifier => Identifier); end Lookup; ------------------------------------------------------------------------- procedure Reset is begin Instance.Reset; end Reset; ------------------------------------------------------------------------- procedure Set_Default_Loglevel (Level : Log_Level) is begin Instance.Set_Default_Loglevel (Level => Level); end Set_Default_Loglevel; ------------------------------------------------------------------------- procedure Set_Loglevel (Identifier : String; Level : Log_Level) is begin Instance.Set_Loglevel (Identifier => Identifier, Level => Level); end Set_Loglevel; ------------------------------------------------------------------------- procedure Set_Loglevel (Identifiers : Maps.Wildcard_Level_Map) is begin Instance.Set_Loglevel (Identifiers => Identifiers); end Set_Loglevel; end Alog.Policy_DB; libalog-0.5.0/src/alog-policy_db.ads000066400000000000000000000066271241767602000173110ustar00rootroot00000000000000-- -- Copyright (c) 2009, -- Reto Buerki, Adrian-Ken Rueegsegger -- -- This file is part of Alog. -- -- Alog is free software; you can redistribute it and/or modify -- it under the terms of the GNU Lesser General Public License as published -- by the Free Software Foundation; either version 2.1 of the License, or -- (at your option) any later version. -- -- Alog is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public License -- along with Alog; if not, write to the Free Software -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, -- MA 02110-1301 USA -- with Alog.Maps; -- Logging policy database package. This DB stores logging policies. Policies -- in the database are used inside the framework for logging decisions. package Alog.Policy_DB is Alog_Default_Level : constant Log_Level := Info; -- Framework default loglevel. procedure Set_Default_Loglevel (Level : Log_Level); -- Set given loglevel as default loglevel. function Get_Default_Loglevel return Log_Level; -- Return current default loglevel. procedure Set_Loglevel (Identifier : String; Level : Log_Level); -- Set given loglevel for specified identifier string. If the identifier is -- already present the loglevel is updated. Identifier strings are -- case-sensitive. -- -- Use wildcards to specify a loglevel for a range of identifiers. -- Identifier hierarchies are separated by dots, the wildcard is '*'. The -- following example sets a Debug loglevel for all log-identifiers in -- Foo.Bar (including Foo.Bar). -- -- Example: -- Foo.Bar.* = Debug -- -- Direct matches take precedence over wildcard matches. In the following -- example the loglevel for identifier 'Foo.Bar' is explicitly set to Info. -- -- Example: -- Foo.Bar = Info -- Foo.Bar.* = Debug procedure Set_Loglevel (Identifiers : Maps.Wildcard_Level_Map); -- Apply loglevels for identifiers stored in map. function Get_Loglevel (Identifier : String) return Log_Level; -- Return loglevel for given identifier string. Raises No_Ident_Loglevel -- exception if no entry for given identifier is found (exact match only, -- no wildcard lookup). function Lookup (Identifier : String) return Log_Level; -- Return loglevel for given identifier string. Returns the closest match, -- if no associated loglevel is found the default loglevel is returned. procedure Reset; -- Reset the logging policy database to the initial state. function Accept_Src (Identifier : String := ""; Level : Log_Level) return Boolean; -- Returns True if the given loglevel is accepted for a source identifier. -- If no identifier is given, the loglevel is verified against the default -- loglevel. function Accept_Dst (Identifier : String; Level : Log_Level) return Boolean; -- Returns True if the given loglevel is accepted for a destination -- identifier. If no match for the given identifier is found True is -- returned. No_Ident_Loglevel : exception; -- Will be raised if loglevel is not found for a requested identifier. end Alog.Policy_DB; libalog-0.5.0/src/alog-protected_containers.adb000066400000000000000000000052721241767602000215350ustar00rootroot00000000000000-- -- Copyright (c) 2009, -- Reto Buerki, Adrian-Ken Rueegsegger -- -- This file is part of Alog. -- -- Alog is free software; you can redistribute it and/or modify -- it under the terms of the GNU Lesser General Public License as published -- by the Free Software Foundation; either version 2.1 of the License, or -- (at your option) any later version. -- -- Alog is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public License -- along with Alog; if not, write to the Free Software -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, -- MA 02110-1301 USA -- package body Alog.Protected_Containers is ------------------------------------------------------------------------- protected body Log_Request_List is ---------------------------------------------------------------------- entry All_Done when Requests.Is_Empty and then Pending_Counter = 0 is begin null; end All_Done; ---------------------------------------------------------------------- procedure Clear is begin Requests.Clear; Pending_Counter := 0; end Clear; ---------------------------------------------------------------------- procedure Done is begin if Pending_Counter = 0 then return; end if; Pending_Counter := Pending_Counter - 1; end Done; ---------------------------------------------------------------------- entry Get (Element : out Log_Request.Instance) when Requests_Available is begin Element := Requests.First_Element; Requests.Delete_First; Pending_Counter := Pending_Counter + 1; if Requests.Is_Empty then Requests_Available := False; end if; end Get; ---------------------------------------------------------------------- function Length return Natural is begin return Natural (Requests.Length); end Length; ---------------------------------------------------------------------- function Pending return Natural is begin return Pending_Counter; end Pending; ---------------------------------------------------------------------- procedure Put (Element : Log_Request.Instance) is begin Requests.Append (New_Item => Element); Requests_Available := True; end Put; end Log_Request_List; end Alog.Protected_Containers; libalog-0.5.0/src/alog-protected_containers.ads000066400000000000000000000053141241767602000215530ustar00rootroot00000000000000-- -- Copyright (c) 2009, -- Reto Buerki, Adrian-Ken Rueegsegger -- -- This file is part of Alog. -- -- Alog is free software; you can redistribute it and/or modify -- it under the terms of the GNU Lesser General Public License as published -- by the Free Software Foundation; either version 2.1 of the License, or -- (at your option) any later version. -- -- Alog is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public License -- along with Alog; if not, write to the Free Software -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, -- MA 02110-1301 USA -- with Ada.Containers.Doubly_Linked_Lists; with Alog.Log_Request; -- Alog Protected Containers. This package provides protected containers which -- are safe for concurrent access. package Alog.Protected_Containers is ---------------------- -- Log_Request_List -- ---------------------- type Log_Request_Storage is private; protected type Log_Request_List is procedure Put (Element : Log_Request.Instance); -- Put an element at the end of the request list. entry Get (Element : out Log_Request.Instance); -- Get the first element from the list (and delete it). procedure Done; -- Signal successfull processing of request previously gotten from list. entry All_Done; -- This procedure blocks until the list is empty and there are no -- pending requests. A requests is pending when it is taken off the list -- via Get but it's successfull processing has not been signaled back -- via the procedure Done. procedure Clear; -- Clear the request list by deleting all log requests. function Length return Natural; -- Return the number of elements in the list. function Pending return Natural; -- Return the number of pending requests. private Requests : Log_Request_Storage; Requests_Available : Boolean := False; Pending_Counter : Natural := 0; end Log_Request_List; -- Protected variant of a log request list. This list holds log request -- objects and is safe for concurrent access. It operates in FIFO-Mode. private use type Alog.Log_Request.Instance; package List_Of_Log_Requests_Package is new Ada.Containers.Doubly_Linked_Lists (Element_Type => Log_Request.Instance); package LOLRP renames List_Of_Log_Requests_Package; type Log_Request_Storage is new LOLRP.List with null record; end Alog.Protected_Containers; libalog-0.5.0/src/alog-tasked_logger.adb000066400000000000000000000207761241767602000201370ustar00rootroot00000000000000-- -- Copyright (c) 2009-2012, -- Reto Buerki, Adrian-Ken Rueegsegger -- -- This file is part of Alog. -- -- Alog is free software; you can redistribute it and/or modify -- it under the terms of the GNU Lesser General Public License as published -- by the Free Software Foundation; either version 2.1 of the License, or -- (at your option) any later version. -- -- Alog is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public License -- along with Alog; if not, write to the Free Software -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, -- MA 02110-1301 USA -- with Ada.Text_IO; with Ada.Exceptions; with Ada.Strings.Unbounded; with Alog.Logger; package body Alog.Tasked_Logger is use Ada.Strings.Unbounded; procedure F_Dummy (Facility_Handle : Facilities.Handle) is null; -- This procedure is needed to initialize the 'Current_Facility_Proc' -- handle of type Facility_Update_Handle since that type is defined as -- 'not null'. procedure Default_Handler (Except : Ada.Exceptions.Exception_Occurrence; Caller : Ada.Task_Identification.Task_Id); -- Tasked logger default exception handling callback. Prints the calling -- task's ID and exception information to stderr. ------------------------------------------------------------------------- procedure Default_Handler (Except : Ada.Exceptions.Exception_Occurrence; Caller : Ada.Task_Identification.Task_Id) is use Ada.Task_Identification; begin Ada.Text_IO.Put_Line (File => Ada.Text_IO.Current_Error, Item => "Logging exception while processing request for task with ID " & Image (T => Caller)); Ada.Text_IO.Put_Line (File => Ada.Text_IO.Current_Error, Item => Ada.Exceptions.Exception_Information (Except)); end Default_Handler; ------------------------------------------------------------------------- task body Instance is use type Ada.Task_Identification.Task_Id; Except_Handler : Exceptions.Exception_Handler := Default_Handler'Access; -- Exception handler callback, initialized to default handler. Logsink : Alog.Logger.Instance (Init => Init); Current_Source : Unbounded_String; Current_Level : Log_Level; Current_Message : Unbounded_String; Current_Caller : Ada.Task_Identification.Task_Id; Current_Facility_Name : Unbounded_String; Current_Facility_Proc : Facility_Update_Handle := F_Dummy'Access; begin Main_Loop : loop begin select ------------------------------------------------------------- accept Attach_Facility (Facility : Facilities.Handle) do Logsink.Attach_Facility (Facility => Facility); end Attach_Facility; or ------------------------------------------------------------- accept Attach_Default_Facility do Logsink.Attach_Default_Facility; end Attach_Default_Facility; or ------------------------------------------------------------- accept Detach_Facility (Name : String) do Logsink.Detach_Facility (Name => Name); end Detach_Facility; or ------------------------------------------------------------- accept Detach_Default_Facility do Logsink.Detach_Default_Facility; end Detach_Default_Facility; or ------------------------------------------------------------- accept Facility_Count (Count : out Natural) do Count := Logsink.Facility_Count; end Facility_Count; or ------------------------------------------------------------- accept Update (Name : String; Process : Facility_Update_Handle) do Current_Facility_Name := To_Unbounded_String (Name); Current_Facility_Proc := Process; Current_Caller := Instance.Update'Caller; end Update; begin Logsink.Update (Name => To_String (Current_Facility_Name), Process => Current_Facility_Proc); exception when E : others => Except_Handler (Except => E, Caller => Current_Caller); end; or ------------------------------------------------------------- accept Iterate (Process : Facility_Update_Handle) do Current_Facility_Proc := Process; Current_Caller := Instance.Iterate'Caller; end Iterate; begin Logsink.Iterate (Process => Current_Facility_Proc); exception when E : others => Except_Handler (Except => E, Caller => Current_Caller); end; or ------------------------------------------------------------- accept Attach_Transform (Transform : Transforms.Handle) do Logsink.Attach_Transform (Transform => Transform); end Attach_Transform; or ------------------------------------------------------------- accept Detach_Transform (Name : String) do Logsink.Detach_Transform (Name => Name); end Detach_Transform; or ------------------------------------------------------------- accept Transform_Count (Count : out Natural) do Count := Logsink.Transform_Count; end Transform_Count; or ------------------------------------------------------------- accept Clear do Logsink.Clear; end Clear; or ------------------------------------------------------------- accept Log_Message (Level : Log_Level; Msg : String; Source : String := ""; Caller : Ada.Task_Identification.Task_Id := Ada.Task_Identification.Null_Task_Id) do Current_Source := To_Unbounded_String (Source); Current_Level := Level; Current_Message := To_Unbounded_String (Msg); -- Log_Message'Caller can not be used as default parameter -- so we need to check for 'Null_Task_Id' instead. if Caller = Ada.Task_Identification.Null_Task_Id then Current_Caller := Log_Message'Caller; else Current_Caller := Caller; end if; end Log_Message; begin Logsink.Log_Message (Source => To_String (Current_Source), Level => Current_Level, Msg => To_String (Current_Message)); exception when E : others => Except_Handler (Except => E, Caller => Current_Caller); end; or ------------------------------------------------------------- accept Shutdown; exit Main_Loop; or ----------------------------------------------------------- accept Set_Except_Handler (Proc : Exceptions.Exception_Handler) do Except_Handler := Proc; end Set_Except_Handler; or terminate; end select; -- Exceptions raised during a rendezvous are raised here and in -- the calling task. Catch and ignore it so the tasked logger does -- not get terminated after an exception. exception when others => null; end; end loop Main_Loop; end Instance; end Alog.Tasked_Logger; libalog-0.5.0/src/alog-tasked_logger.ads000066400000000000000000000103231241767602000201430ustar00rootroot00000000000000-- -- Copyright (c) 2009-2012, -- Reto Buerki, Adrian-Ken Rueegsegger -- -- This file is part of Alog. -- -- Alog is free software; you can redistribute it and/or modify -- it under the terms of the GNU Lesser General Public License as published -- by the Free Software Foundation; either version 2.1 of the License, or -- (at your option) any later version. -- -- Alog is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public License -- along with Alog; if not, write to the Free Software -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, -- MA 02110-1301 USA -- with Ada.Task_Identification; with Alog.Exceptions; with Alog.Facilities; with Alog.Transforms; -- Tasked Logger instance. Facilities can be attached to this logger instance -- in order to log to different targets simultaneously. This instance provides -- task-safe concurrent logging. package Alog.Tasked_Logger is type Facility_Update_Handle is not null access procedure (Facility_Handle : Facilities.Handle); -- Handle to facility update procedure. task type Instance (Init : Boolean := False) is entry Attach_Facility (Facility : Facilities.Handle); -- Attach a facility to tasked logger instance. entry Attach_Default_Facility; -- Attach default facility to tasked logger instance. entry Detach_Facility (Name : String); -- Detach a facility from tasked logger instance. entry Detach_Default_Facility; -- Detach default facility from tasked logger instance. entry Facility_Count (Count : out Natural); -- Return number of attached facilites. entry Update (Name : String; Process : Facility_Update_Handle); -- Update a specific facility identified by 'Name'. Calls the 'Process' -- procedure to perform the update operation. entry Iterate (Process : Facility_Update_Handle); -- Call 'Process' for all attached facilities. entry Attach_Transform (Transform : Transforms.Handle); -- Attach a transform to tasked logger instance. entry Detach_Transform (Name : String); -- Detach a transform from tasked logger instance. entry Transform_Count (Count : out Natural); -- Return number of attached transforms. entry Log_Message (Level : Log_Level; Msg : String; Source : String := ""; Caller : Ada.Task_Identification.Task_Id := Ada.Task_Identification.Null_Task_Id); -- Log a message. The Write_Message() procedure of all attached -- facilities is called. Depending on the Log-Threshold set, the message -- is logged to different targets (depending on the facilites) -- automatically. If an exception occurs, the exception handler -- procedure is called. -- -- If caller is not specified the executing task's ID is used instead. -- Since Log_Message'Caller can not be used as default parameter the -- entry checks if the variable is set to 'Null_Task_Id' in the body. entry Clear; -- Clear tasked logger instance. Detach and teardown all attached -- facilities and transforms and clear any stored exceptions. entry Shutdown; -- Explicitly shutdown tasked logger. entry Set_Except_Handler (Proc : Exceptions.Exception_Handler); -- Set custom exception handler procedure. end Instance; -- Tasked logger instance. The Init discriminant defines whether or not a -- default 'stdout' (FD facility without logfile set) is attached -- automatically. Default is 'False'. Set Init to 'True' if you want to -- make sure minimal stdout logging is possible as soon as a new logger is -- instantiated. -- -- By default exceptions which occur during asynchronous processing are -- printed to standard error. Use the Set_Except_Handler entry to register -- a custom exception handler. type Handle is access all Instance; -- Handle to tasked logger type. end Alog.Tasked_Logger; libalog-0.5.0/src/alog-transforms-casing.adb000066400000000000000000000031601241767602000207510ustar00rootroot00000000000000-- -- Copyright (c) 2008, -- Reto Buerki, Adrian-Ken Rueegsegger -- -- This file is part of Alog. -- -- Alog is free software; you can redistribute it and/or modify -- it under the terms of the GNU Lesser General Public License as published -- by the Free Software Foundation; either version 2.1 of the License, or -- (at your option) any later version. -- -- Alog is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public License -- along with Alog; if not, write to the Free Software -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, -- MA 02110-1301 USA -- with Ada.Characters.Handling; package body Alog.Transforms.Casing is ------------------------------------------------------------------------- procedure Set_Mode (Transform : in out Instance; Mode : Operation_Mode) is begin Transform.Mode := Mode; end Set_Mode; ------------------------------------------------------------------------- function Transform_Message (Transform : Instance; Level : Log_Level := Info; Msg : String) return String is pragma Unreferenced (Level); begin if Transform.Mode = Lowercase then return Ada.Characters.Handling.To_Lower (Msg); else return Ada.Characters.Handling.To_Upper (Msg); end if; end Transform_Message; end Alog.Transforms.Casing; libalog-0.5.0/src/alog-transforms-casing.ads000066400000000000000000000031671241767602000210010ustar00rootroot00000000000000-- -- Copyright (c) 2008, -- Reto Buerki, Adrian-Ken Rueegsegger -- -- This file is part of Alog. -- -- Alog is free software; you can redistribute it and/or modify -- it under the terms of the GNU Lesser General Public License as published -- by the Free Software Foundation; either version 2.1 of the License, or -- (at your option) any later version. -- -- Alog is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public License -- along with Alog; if not, write to the Free Software -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, -- MA 02110-1301 USA -- -- Casing transform. Used to transform casing (lower/uppercase) of messages package Alog.Transforms.Casing is type Operation_Mode is (Uppercase, Lowercase); type Instance is new Alog.Transforms.Instance with private; -- Casing transform. type Handle is access all Instance; overriding function Transform_Message (Transform : Instance; Level : Log_Level := Info; Msg : String) return String; -- Implementation of Transform_Message. procedure Set_Mode (Transform : in out Instance; Mode : Operation_Mode); -- Set operation mode of transform. private type Instance is new Alog.Transforms.Instance with record Mode : Operation_Mode := Lowercase; -- Mode of operation. end record; end Alog.Transforms.Casing; libalog-0.5.0/src/alog-transforms.adb000066400000000000000000000030451241767602000175110ustar00rootroot00000000000000-- -- Copyright (c) 2008, -- Reto Buerki, Adrian-Ken Rueegsegger -- -- This file is part of Alog. -- -- Alog is free software; you can redistribute it and/or modify -- it under the terms of the GNU Lesser General Public License as published -- by the Free Software Foundation; either version 2.1 of the License, or -- (at your option) any later version. -- -- Alog is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public License -- along with Alog; if not, write to the Free Software -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, -- MA 02110-1301 USA -- package body Alog.Transforms is ------------------------------------------------------------------------- function "=" (Left : Handle; Right : Handle) return Boolean is begin return Left.Get_Name = Right.Get_Name; end "="; ------------------------------------------------------------------------- function Get_Name (Transform : Class) return String is begin return To_String (Transform.Name); end Get_Name; ------------------------------------------------------------------------- procedure Set_Name (Transform : in out Class; Name : String) is begin Transform.Name := To_Unbounded_String (Name); end Set_Name; end Alog.Transforms; libalog-0.5.0/src/alog-transforms.ads000066400000000000000000000046751241767602000175440ustar00rootroot00000000000000-- -- Copyright (c) 2008, -- Reto Buerki, Adrian-Ken Rueegsegger -- -- This file is part of Alog. -- -- Alog is free software; you can redistribute it and/or modify -- it under the terms of the GNU Lesser General Public License as published -- by the Free Software Foundation; either version 2.1 of the License, or -- (at your option) any later version. -- -- Alog is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public License -- along with Alog; if not, write to the Free Software -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, -- MA 02110-1301 USA -- with Ada.Strings.Unbounded; -- Abstract package Transforms. Provides methods used by all Alog transforms. package Alog.Transforms is use Ada.Strings.Unbounded; type Instance is abstract tagged limited private; -- Abstract type transform instance. All tranforms in the Alog framework -- must implement this type. subtype Class is Instance'Class; type Handle is access Class; function "=" (Left : Handle; Right : Handle) return Boolean; -- Equal function. procedure Set_Name (Transform : in out Class; Name : String); -- Set transform name. function Get_Name (Transform : Class) return String; -- Get transform name. function Transform_Message (Transform : Instance; Level : Log_Level; Msg : String) return String is abstract; -- Transform message with specified log level. procedure Setup (Transform : in out Instance) is null; -- Each transform must provide a Setup-procedure. These procedures are -- called by logger instances when attaching Transforms. All needed -- operations prior to transforming log messages should be done here. procedure Teardown (Transform : in out Instance) is null; -- Each transform must provide a Teardown-procedure. These procedures are -- called by logger instances when detaching Transforms or when the logger -- object gets out of scope. private type Instance is abstract tagged limited record Name : Unbounded_String := To_Unbounded_String ("sample-transform"); -- Transform Name. Names must be unique. end record; end Alog.Transforms; libalog-0.5.0/src/alog.ads000066400000000000000000000027031241767602000153360ustar00rootroot00000000000000-- -- Copyright (c) 2008, -- Reto Buerki, Adrian-Ken Rueegsegger -- -- This file is part of Alog. -- -- Alog is free software; you can redistribute it and/or modify -- it under the terms of the GNU Lesser General Public License as published -- by the Free Software Foundation; either version 2.1 of the License, or -- (at your option) any later version. -- -- Alog is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public License -- along with Alog; if not, write to the Free Software -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, -- MA 02110-1301 USA -- pragma Detect_Blocking; -- Alog: Ada Logging Components. Provides easy to use API for different -- logging facilities and log message transforms. package Alog is pragma Preelaborate; type Log_Level is (Debug, Info, Notice, Warning, Error, Critical, Alert, Emergency); -- Provided log levels. These log levels can be used to categorize log -- messages. Max_Path_Length : constant Natural := 1024; -- Maximal length of path names. Max_Facilities : constant Natural := 15; -- Maximum number of facilities a single logger instance -- can manage. end Alog; libalog-0.5.0/src/glue_syslog.c000066400000000000000000000021621241767602000164220ustar00rootroot00000000000000/* * Copyright (c) 2011, * Reto Buerki, Adrian-Ken Rueegsegger * * This file is part of Alog. * * Alog is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * Alog is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with Alog; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, * MA 02110-1301 USA * * Wrapper for syslog C function which has variable arguments, see GNAT User's * Guide, section 2.10.2, Calling Conventions: * http://gcc.gnu.org/onlinedocs/gnat_ugn_unw/Calling-Conventions.html */ #include void syslog_wrapper(int priority, const char *message) { syslog(priority, "%s", message); } libalog-0.5.0/tests/000077500000000000000000000000001241767602000142745ustar00rootroot00000000000000libalog-0.5.0/tests/active_logger_tests.adb000066400000000000000000000456721241767602000210160ustar00rootroot00000000000000-- -- Copyright (c) 2008-2011, -- Reto Buerki, Adrian-Ken Rueegsegger -- -- This file is part of Alog. -- -- Alog is free software; you can redistribute it and/or modify -- it under the terms of the GNU Lesser General Public License as published -- by the Free Software Foundation; either version 2.1 of the License, or -- (at your option) any later version. -- -- Alog is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public License -- along with Alog; if not, write to the Free Software -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, -- MA 02110-1301 USA -- with Ada.Directories; with Ahven; with Alog.Helpers; with Alog.Facilities.File_Descriptor; with Alog.Facilities.Syslog; with Alog.Transforms.Casing; with Alog.Logger; with Alog.Active_Logger; package body Active_Logger_Tests is use Ahven; use Alog; Ref_Facility_Name : constant String := "Test_Facility_Name"; Counter : Natural := 0; pragma Atomic (Counter); procedure Check_Facility (Facility_Handle : Facilities.Handle); -- Verify that facility with given name is present in the logger. procedure Inc_Counter (F_Handle : Facilities.Handle); -- Increment counter. procedure Toggle_Timestamp (Facility_Handle : Facilities.Handle); -- Helper function for update facility test: Set the facility's write -- timestamp flag to True. ------------------------------------------------------------------------- procedure Attach_Facility is Log : aliased Active_Logger.Instance (Init => False); Facility : constant Facilities.Handle := new Facilities.File_Descriptor.Instance; begin Facility.Set_Name (Name => Ref_Facility_Name); declare Shutdown : Active_Logger.Shutdown_Helper (Logger => Log'Access); pragma Unreferenced (Shutdown); begin Assert (Condition => Log.Facility_Count = 0, Message => "Facility count not 0"); Log.Attach_Facility (Facility => Facility); Assert (Condition => Log.Facility_Count = 1, Message => "Could not attach facility"); Log.Update (Name => Facility.Get_Name, Process => Check_Facility'Access); begin Log.Attach_Facility (Facility => Facility); Fail (Message => "Attached duplicate facility"); exception when Logger.Facility_Already_Present => null; end; end; end Attach_Facility; ------------------------------------------------------------------------- procedure Attach_Transform is Log : aliased Active_Logger.Instance (Init => False); Transform : constant Transforms.Handle := new Transforms.Casing.Instance; begin declare Shutdown : Active_Logger.Shutdown_Helper (Logger => Log'Access); pragma Unreferenced (Shutdown); begin Assert (Condition => Log.Transform_Count = 0, Message => "transform count not 0"); Log.Attach_Transform (Transform => Transform); Assert (Condition => Log.Transform_Count = 1, Message => "could not attach transform"); begin Log.Attach_Transform (Transform => Transform); Fail (Message => "attached duplicate transform"); exception when Logger.Transform_Already_Present => null; end; end; end Attach_Transform; ------------------------------------------------------------------------- procedure Check_Facility (Facility_Handle : Facilities.Handle) is use type Facilities.Handle; begin Assert (Condition => Facility_Handle.Get_Name = Ref_Facility_Name, Message => "facility name mismatch"); end Check_Facility; ------------------------------------------------------------------------- procedure Clear_A_Logger is Log : aliased Active_Logger.Instance (Init => False); Facility : constant Facilities.Handle := new Facilities.File_Descriptor.Instance; Transform : constant Transforms.Handle := new Transforms.Casing.Instance; begin declare Shutdown : Active_Logger.Shutdown_Helper (Logger => Log'Access); pragma Unreferenced (Shutdown); begin Log.Attach_Facility (Facility => Facility); Assert (Condition => Log.Facility_Count = 1, Message => "could not attach facility"); Log.Attach_Transform (Transform => Transform); Assert (Condition => Log.Transform_Count = 1, Message => "could not attach transform"); Log.Clear; Assert (Condition => Log.Facility_Count = 0, Message => "facility count is not 0"); Assert (Condition => Log.Transform_Count = 0, Message => "transform count is not 0"); end; end Clear_A_Logger; ------------------------------------------------------------------------- procedure Default_Facility_Handling is Logger1 : aliased Active_Logger.Instance (Init => False); Logger2 : aliased Active_Logger.Instance (Init => True); begin declare Shutdown1 : Active_Logger.Shutdown_Helper (Logger => Logger1'Access); Shutdown2 : Active_Logger.Shutdown_Helper (Logger => Logger2'Access); pragma Unreferenced (Shutdown1); pragma Unreferenced (Shutdown2); begin Logger1.Attach_Default_Facility; Assert (Condition => Logger1.Facility_Count = 1, Message => "Unable to attach facility"); Logger1.Attach_Default_Facility; Assert (Condition => Logger1.Facility_Count = 1, Message => "Attached facility twice"); Logger1.Log_Message (Level => Debug, Msg => "Testing default logger"); Logger1.Detach_Default_Facility; Assert (Condition => Logger1.Facility_Count = 0, Message => "Unable to detach facility"); Logger2.Attach_Default_Facility; Assert (Condition => Logger2.Facility_Count = 1, Message => "Attached facility to initialzed logger"); Logger2.Detach_Default_Facility; Assert (Condition => Logger2.Facility_Count = 0, Message => "Unable to detach facility from initialized" & " logger"); end; end Default_Facility_Handling; ------------------------------------------------------------------------- procedure Detach_Facility_Instance is Log : aliased Active_Logger.Instance (Init => False); Facility : constant Facilities.Handle := new Facilities.Syslog.Instance; begin declare Shutdown : Active_Logger.Shutdown_Helper (Logger => Log'Access); pragma Unreferenced (Shutdown); begin Facility.Set_Name ("Syslog_Facility"); Log.Attach_Facility (Facility => Facility); Assert (Condition => Log.Facility_Count = 1, Message => "could not attach"); Log.Detach_Facility (Name => Facility.Get_Name); Assert (Condition => Log.Facility_Count = 0, Message => "could not detach"); end; end Detach_Facility_Instance; ------------------------------------------------------------------------- procedure Detach_Facility_Unattached is Log : aliased Active_Logger.Instance (Init => False); Facility : Facilities.Handle := new Facilities.File_Descriptor.Instance; begin declare Shutdown : Active_Logger.Shutdown_Helper (Logger => Log'Access); pragma Unreferenced (Shutdown); begin Log.Detach_Facility (Name => Facility.Get_Name); Fail (Message => "could detach unattached facility"); exception when Logger.Facility_Not_Found => -- Free not attached facility, this is not done by the logger -- (since it was never attached). Alog.Logger.Free (Facility); -- Test passed. end; end Detach_Facility_Unattached; ------------------------------------------------------------------------- procedure Detach_Transform_Instance is Log : aliased Active_Logger.Instance (Init => False); Transform : constant Transforms.Handle := new Transforms.Casing.Instance; begin declare Shutdown : Active_Logger.Shutdown_Helper (Logger => Log'Access); pragma Unreferenced (Shutdown); begin Transform.Set_Name ("Casing_Transform"); Log.Attach_Transform (Transform => Transform); Assert (Condition => Log.Transform_Count = 1, Message => "could not attach"); Log.Detach_Transform (Name => Transform.Get_Name); Assert (Condition => Log.Transform_Count = 0, Message => "could not detach"); end; end Detach_Transform_Instance; ------------------------------------------------------------------------- procedure Detach_Transform_Unattached is Log : aliased Active_Logger.Instance (Init => False); Transform : Transforms.Handle := new Transforms.Casing.Instance; begin declare Shutdown : Active_Logger.Shutdown_Helper (Logger => Log'Access); pragma Unreferenced (Shutdown); begin Transform.Set_Name ("Casing_Transform"); Log.Detach_Transform (Name => Transform.Get_Name); Fail (Message => "could detach unattached transform"); exception when Logger.Transform_Not_Found => -- Free not attached Transform, this is not done by the logger -- (since it was never attached). Alog.Logger.Free (Transform); -- Test passed. end; end Detach_Transform_Unattached; ------------------------------------------------------------------------- procedure Inc_Counter (F_Handle : Facilities.Handle) is pragma Unreferenced (F_Handle); begin Counter := Counter + 1; end Inc_Counter; ------------------------------------------------------------------------- procedure Initialize (T : in out Testcase) is begin T.Set_Name (Name => "Tests for active Logger"); T.Add_Test_Routine (Routine => Attach_Facility'Access, Name => "attach a facility"); T.Add_Test_Routine (Routine => Update_Facility'Access, Name => "update a facility"); T.Add_Test_Routine (Routine => Detach_Facility_Instance'Access, Name => "detach facility: instance"); T.Add_Test_Routine (Routine => Detach_Facility_Unattached'Access, Name => "detach not attached facility"); T.Add_Test_Routine (Routine => Attach_Transform'Access, Name => "attach a transform"); T.Add_Test_Routine (Routine => Detach_Transform_Instance'Access, Name => "detach a transform"); T.Add_Test_Routine (Routine => Detach_Transform_Unattached'Access, Name => "detach not attached transform"); T.Add_Test_Routine (Routine => Clear_A_Logger'Access, Name => "clear logger"); T.Add_Test_Routine (Routine => Verify_Logger_Initialization'Access, Name => "logger initialization behavior"); T.Add_Test_Routine (Routine => Default_Facility_Handling'Access, Name => "default facility handling"); T.Add_Test_Routine (Routine => Tasked_One_FD_Facility'Access, Name => "log with active logger"); T.Add_Test_Routine (Routine => Verify_Iterate_Facilities'Access, Name => "verify iterate facilities"); T.Add_Test_Routine (Routine => Task_Termination'Access, Name => "task termination"); T.Add_Test_Routine (Routine => Request_Queue_Length'Access, Name => "request queue length"); end Initialize; ------------------------------------------------------------------------- procedure Request_Queue_Length is Log : aliased Active_Logger.Instance (Init => False); begin declare Shutdown : Active_Logger.Shutdown_Helper (Logger => Log'Access); pragma Unreferenced (Shutdown); begin Assert (Condition => Log.Get_Queue_Length = 0, Message => "Queue not empty"); end; end Request_Queue_Length; ------------------------------------------------------------------------- procedure Task_Termination is Log : aliased Active_Logger.Instance (Init => False); begin declare Shutdown : Active_Logger.Shutdown_Helper (Logger => Log'Access); pragma Unreferenced (Shutdown); begin Assert (Condition => Log.Is_Terminated = False, Message => "New Logger terminated"); declare Counter : Natural := 0; begin Log.Shutdown; while not Log.Is_Terminated loop delay 0.01; Counter := Counter + 1; if Counter = 200 then Fail (Message => "Logger still running"); end if; end loop; end; end; end Task_Termination; ------------------------------------------------------------------------- procedure Tasked_One_FD_Facility is Log : aliased Active_Logger.Instance (Init => False); Fd_Facility1 : constant Facilities.Handle := new Facilities.File_Descriptor.Instance; Fd_Facility2 : constant Facilities.Handle := new Facilities.File_Descriptor.Instance; Testfile : constant String := "./data/Active_Tasked_FD_Facility"; Reffile : constant String := "./data/Tasked_FD_Facility.ref"; Test_Message : constant String := "logger tasked test message"; Nr_Of_Messages : constant Natural := 10; task type Test_Log_Task (Logger : not null access Active_Logger.Instance); -- This task logs Nr_Of_Messages to the given Active logger instance. task body Test_Log_Task is begin for I in 1 .. Nr_Of_Messages loop Logger.Log_Message (Level => Debug, Msg => Test_Message); end loop; end Test_Log_Task; begin declare Shutdown : Active_Logger.Shutdown_Helper (Logger => Log'Access); pragma Unreferenced (Shutdown); begin Fd_Facility1.Set_Name (Name => "Fd_Facility1"); Fd_Facility1.Toggle_Write_Timestamp (State => False); Facilities.File_Descriptor.Handle (Fd_Facility1).Set_Logfile (Path => Testfile); Log.Attach_Facility (Facility => Fd_Facility1); Log.Attach_Facility (Facility => Fd_Facility2); Assert (Condition => Log.Facility_Count = 2, Message => "facility count not 2"); Log.Detach_Facility (Name => Fd_Facility2.Get_Name); Assert (Condition => Log.Facility_Count = 1, Message => "facility count not 1"); declare Logger1 : Test_Log_Task (Log'Access); begin for I in 1 .. Nr_Of_Messages loop Log.Log_Message (Level => Debug, Msg => Test_Message); end loop; end; end; Assert (Condition => Helpers.Assert_Files_Equal (Filename1 => Reffile, Filename2 => Testfile), Message => "files not equal"); Ada.Directories.Delete_File (Name => Testfile); end Tasked_One_FD_Facility; ------------------------------------------------------------------------- procedure Toggle_Timestamp (Facility_Handle : Facilities.Handle) is begin Facility_Handle.Toggle_Write_Timestamp (State => True); end Toggle_Timestamp; ------------------------------------------------------------------------- procedure Update_Facility is Log : aliased Active_Logger.Instance (Init => False); begin declare Shutdown : Active_Logger.Shutdown_Helper (Logger => Log'Access); pragma Unreferenced (Shutdown); begin declare Facility : constant Facilities.Handle := new Facilities.File_Descriptor.Instance; Facility_Name : constant String := "Test_Facility"; begin Facility.Set_Name (Name => Facility_Name); Facility.Toggle_Write_Timestamp (State => False); Assert (Condition => not Facility.Is_Write_Timestamp, Message => "Could not disable Timestamp"); Log.Attach_Facility (Facility => Facility); Log.Update (Name => Facility_Name, Process => Toggle_Timestamp'Access); for I in 1 .. 30 loop exit when Facility.Is_Write_Timestamp; delay 0.1; end loop; Assert (Condition => Facility.Is_Write_Timestamp, Message => "Update failed"); end; end; end Update_Facility; ------------------------------------------------------------------------- procedure Verify_Iterate_Facilities is Log : aliased Active_Logger.Instance (Init => False); Facility1 : constant Facilities.Handle := new Facilities.File_Descriptor.Instance; Facility2 : constant Facilities.Handle := new Facilities.File_Descriptor.Instance; begin declare Shutdown : Active_Logger.Shutdown_Helper (Logger => Log'Access); pragma Unreferenced (Shutdown); begin Facility1.Set_Name (Name => "Facility1"); Facility1.Set_Name (Name => "Facility2"); Log.Attach_Facility (Facility => Facility1); Log.Attach_Facility (Facility => Facility2); Log.Iterate (Process => Inc_Counter'Access); for I in 1 .. 30 loop exit when Counter /= 0; delay 0.1; end loop; Assert (Condition => Counter = 2, Message => "Counter not 2"); end; end Verify_Iterate_Facilities; ------------------------------------------------------------------------- procedure Verify_Logger_Initialization is Logger1 : aliased Active_Logger.Instance (Init => False); Logger2 : aliased Active_Logger.Instance (Init => True); begin declare Shutdown1 : Active_Logger.Shutdown_Helper (Logger => Logger1'Access); Shutdown2 : Active_Logger.Shutdown_Helper (Logger => Logger2'Access); pragma Unreferenced (Shutdown1); pragma Unreferenced (Shutdown2); begin Assert (Condition => Logger1.Facility_Count = 0, Message => "logger1 not empty"); Assert (Condition => Logger2.Facility_Count = 1, Message => "logger2 empty"); end; end Verify_Logger_Initialization; end Active_Logger_Tests; libalog-0.5.0/tests/active_logger_tests.ads000066400000000000000000000046151241767602000210270ustar00rootroot00000000000000-- -- Copyright (c) 2008-2011, -- Reto Buerki, Adrian-Ken Rueegsegger -- -- This file is part of Alog. -- -- Alog is free software; you can redistribute it and/or modify -- it under the terms of the GNU Lesser General Public License as published -- by the Free Software Foundation; either version 2.1 of the License, or -- (at your option) any later version. -- -- Alog is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public License -- along with Alog; if not, write to the Free Software -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, -- MA 02110-1301 USA -- with Ahven.Framework; -- Tests for Alog active logger component. package Active_Logger_Tests is type Testcase is new Ahven.Framework.Test_Case with null record; procedure Initialize (T : in out Testcase); -- Initialize testcase. procedure Attach_Facility; -- Test Facility attaching. procedure Update_Facility; -- Test Facility update operation. procedure Detach_Facility_Instance; -- Test Facility detaching by name. procedure Detach_Facility_Unattached; -- Test Facility detaching of active logger with a un-attached instance. -- Verify that logger remains responsive after exception. procedure Attach_Transform; -- Test Transform attaching. procedure Detach_Transform_Instance; -- Test Transform detaching by name. procedure Detach_Transform_Unattached; -- Test Transform detaching of tasked logger with un-attached instance. -- Verify that active logger remains responsive after exception. procedure Clear_A_Logger; -- Test Logger cleanup. procedure Verify_Logger_Initialization; -- Test active logger instance initialization behavior. procedure Default_Facility_Handling; -- Test attaching/detaching of default facility. procedure Tasked_One_FD_Facility; -- Test tasked logging to active logger with one fd based facility. procedure Verify_Iterate_Facilities; -- Test iterate for facilities of active logger. procedure Task_Termination; -- Test active logger task termination. procedure Request_Queue_Length; -- Test queue length getter. end Active_Logger_Tests; libalog-0.5.0/tests/alog-facilities-mock.adb000066400000000000000000000022151241767602000207270ustar00rootroot00000000000000-- -- Copyright (c) 2009, -- Reto Buerki, Adrian-Ken Rueegsegger -- -- This file is part of Alog. -- -- Alog is free software; you can redistribute it and/or modify -- it under the terms of the GNU Lesser General Public License as published -- by the Free Software Foundation; either version 2.1 of the License, or -- (at your option) any later version. -- -- Alog is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public License -- along with Alog; if not, write to the Free Software -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, -- MA 02110-1301 USA package body Alog.Facilities.Mock is ------------------------------------------------------------------------- procedure Write (Facility : Instance; Level : Log_Level := Info; Msg : String) is begin raise Constraint_Error with Exception_Message; end Write; end Alog.Facilities.Mock; libalog-0.5.0/tests/alog-facilities-mock.ads000066400000000000000000000031351241767602000207520ustar00rootroot00000000000000-- -- Copyright (c) 2009, -- Reto Buerki, Adrian-Ken Rueegsegger -- -- This file is part of Alog. -- -- Alog is free software; you can redistribute it and/or modify -- it under the terms of the GNU Lesser General Public License as published -- by the Free Software Foundation; either version 2.1 of the License, or -- (at your option) any later version. -- -- Alog is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public License -- along with Alog; if not, write to the Free Software -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, -- MA 02110-1301 USA -- Logging facility used for testing. Raises a Constraint_Error when Write() -- is called. package Alog.Facilities.Mock is type Instance is new Alog.Facilities.Instance with private; type Handle is access all Instance; overriding procedure Write (Facility : Instance; Level : Log_Level := Info; Msg : String); -- Implementation of Write. overriding procedure Setup (Facility : in out Instance) is null; -- Implementation of Setup procedure. overriding procedure Teardown (Facility : in out Instance) is null; -- Implementation of Teardown procedure. Exception_Message : constant String := "DON'T PANIC! Test exception"; private type Instance is new Alog.Facilities.Instance with null record; end Alog.Facilities.Mock; libalog-0.5.0/tests/facility_tests-fd.adb000066400000000000000000000271241241767602000203670ustar00rootroot00000000000000-- -- Copyright (c) 2008-2009, -- Reto Buerki, Adrian-Ken Rueegsegger -- -- This file is part of Alog. -- -- Alog is free software; you can redistribute it and/or modify -- it under the terms of the GNU Lesser General Public License as published -- by the Free Software Foundation; either version 2.1 of the License, or -- (at your option) any later version. -- -- Alog is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public License -- along with Alog; if not, write to the Free Software -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, -- MA 02110-1301 USA -- with Ada.Text_IO; with Ada.Directories; with Ahven; use Ahven; with Alog.Helpers; with Alog.Log_Request; with Alog.Policy_DB; with Alog.Facilities.File_Descriptor; package body Facility_Tests.FD is use Alog; use Alog.Log_Request; use Alog.Facilities; ------------------------------------------------------------------------- procedure Dst_Loglevel_Handling is F : File_Descriptor.Instance; Testfile : constant String := "./data/Dst_Loglevel_Fd"; Reffile : constant String := "./data/Dst_Loglevel_Fd.ref"; begin F.Toggle_Write_Timestamp (State => False); F.Toggle_Write_Loglevel (State => True); F.Set_Logfile (Path => Testfile); F.Set_Name (Name => "Dst_Facility"); Policy_DB.Set_Loglevel (Identifier => "Dst_Facility", Level => Warning); F.Process (Request => Create (Level => Warning, Message => "Testmessage")); F.Process (Request => Create (Level => Info, Source => "Test", Message => "Testmessage")); F.Close_Logfile; Policy_DB.Reset; Assert (Condition => Helpers.Assert_Files_Equal (Filename1 => Reffile, Filename2 => Testfile), Message => "files not equal"); Ada.Directories.Delete_File (Name => Testfile); end Dst_Loglevel_Handling; ------------------------------------------------------------------------- procedure Initialize (T : in out Testcase) is begin T.Set_Name (Name => "Tests for FD Facility"); T.Add_Test_Routine (Routine => Set_Valid_Logfile_Fd'Access, Name => "set valid logfile"); T.Add_Test_Routine (Routine => Set_Invalid_Logfile_Fd'Access, Name => "set invalid logfile"); T.Add_Test_Routine (Routine => Write_Message_Fd'Access, Name => "log a fd message"); T.Add_Test_Routine (Routine => Teardown_Fd'Access, Name => "teardown fd facility"); T.Add_Test_Routine (Routine => Toggle_Write_Timestamp_Fd'Access, Name => "toggle fd timestamp writing"); T.Add_Test_Routine (Routine => Toggle_Write_Loglevel_Fd'Access, Name => "toggle fd loglevel writing"); T.Add_Test_Routine (Routine => Toggle_Write_Source_Fd'Access, Name => "toggle fd source writing"); T.Add_Test_Routine (Routine => Trim_Loglevels_Fd'Access, Name => "fd loglevel align"); T.Add_Test_Routine (Routine => Verify_Append'Access, Name => "append logic"); T.Add_Test_Routine (Routine => Dst_Loglevel_Handling'Access, Name => "destination loglevels"); end Initialize; ------------------------------------------------------------------------- procedure Set_Invalid_Logfile_Fd is F : File_Descriptor.Instance; begin F.Set_Logfile (Path => "./"); Fail (Message => "expected Name_Error"); exception when File_Descriptor.Open_File_Error => null; end Set_Invalid_Logfile_Fd; ------------------------------------------------------------------------- procedure Set_Valid_Logfile_Fd is use Ada.Text_IO; F : File_Descriptor.Instance; begin F.Set_Logfile (Path => "./data/Set_Valid_Logfile"); Assert (Condition => Is_Open (F.Get_Logfile.all), Message => "could not set logfile!"); F.Close_Logfile (Remove => True); end Set_Valid_Logfile_Fd; ------------------------------------------------------------------------- procedure Teardown_Fd is use Ada.Text_IO; F : File_Descriptor.Instance; Testfile : constant String := "./data/Teardown_Fd"; begin F.Set_Logfile (Path => Testfile); Assert (Condition => Is_Open (File => F.Get_Logfile.all), Message => "could not set logfile!"); F.Teardown; Assert (Condition => not Is_Open (File => F.Get_Logfile.all), Message => "logfile still open!"); Ada.Directories.Delete_File (Name => Testfile); end Teardown_Fd; ------------------------------------------------------------------------- procedure Toggle_Write_Loglevel_Fd is F : File_Descriptor.Instance; Testfile : constant String := "./data/Toggle_Write_Loglevel_Fd"; Reffile : constant String := "./data/Toggle_Write_Loglevel_Fd.ref"; begin F.Toggle_Write_Timestamp (State => False); F.Toggle_Write_Loglevel (State => False); F.Set_Logfile (Path => Testfile); F.Process (Request => Create (Message => "This is a message without loglevel")); F.Close_Logfile; Assert (Condition => Helpers.Assert_Files_Equal (Filename1 => Reffile, Filename2 => Testfile), Message => "unable to disable"); Ada.Directories.Delete_File (Name => Testfile); end Toggle_Write_Loglevel_Fd; ------------------------------------------------------------------------- procedure Toggle_Write_Source_Fd is F : File_Descriptor.Instance; Testfile : constant String := "./data/Toggle_Write_Source_Fd"; Reffile : constant String := "./data/Toggle_Write_Source_Fd.ref"; begin F.Toggle_Write_Timestamp (State => False); F.Toggle_Write_Loglevel (State => True); F.Set_Logfile (Path => Testfile); F.Process (Request => Create (Level => Warning, Message => "No source given")); F.Process (Request => Create (Level => Info, Source => "Test", Message => "Source 'Test'")); F.Toggle_Write_Source (State => False); F.Process (Request => Create (Level => Info, Source => "Test", Message => "Source 'Test', source writing disabled")); F.Close_Logfile; Assert (Condition => Helpers.Assert_Files_Equal (Filename1 => Reffile, Filename2 => Testfile), Message => "file mismatch"); Ada.Directories.Delete_File (Name => Testfile); end Toggle_Write_Source_Fd; ------------------------------------------------------------------------- procedure Toggle_Write_Timestamp_Fd is F : File_Descriptor.Instance; Testfile : constant String := "./data/Toggle_Write_Timestamp_Fd"; Reffile : constant String := "./data/Toggle_Write_Timestamp_Fd.ref"; begin F.Toggle_Write_Timestamp (State => False); F.Set_Logfile (Path => Testfile); F.Process (Request => Create (Message => "This is a message without timestamp")); F.Close_Logfile; Assert (Condition => Helpers.Assert_Files_Equal (Filename1 => Reffile, Filename2 => Testfile), Message => "unable to disable"); Ada.Directories.Delete_File (Name => Testfile); end Toggle_Write_Timestamp_Fd; ------------------------------------------------------------------------- procedure Trim_Loglevels_Fd is F : File_Descriptor.Instance; Testfile : constant String := "./data/Trim_Loglevels_Fd"; Reffile : constant String := "./data/Trim_Loglevels_Fd.ref"; begin F.Toggle_Write_Timestamp (State => False); F.Toggle_Write_Loglevel (State => True); F.Set_Logfile (Path => Testfile); for Lvl in Alog.Log_Level loop F.Process (Request => Create (Level => Lvl, Message => "Testmessage")); end loop; F.Close_Logfile; Assert (Condition => Helpers.Assert_Files_Equal (Filename1 => Reffile, Filename2 => Testfile), Message => "alignment incorrect"); Ada.Directories.Delete_File (Name => Testfile); end Trim_Loglevels_Fd; ------------------------------------------------------------------------- procedure Verify_Append is begin Append : declare F1 : File_Descriptor.Instance; F2 : File_Descriptor.Instance; Testfile : constant String := "./data/Log_Append_Fd"; Reffile : constant String := "./data/Log_Append_Fd.ref"; begin F1.Toggle_Write_Timestamp (State => False); F1.Set_Logfile (Path => Testfile); F1.Process (Request => Create (Message => "Facility1")); F1.Close_Logfile; F2.Toggle_Write_Timestamp (State => False); F2.Set_Logfile (Path => Testfile); F2.Process (Request => Create (Message => "Facility2")); F2.Close_Logfile; Assert (Condition => Helpers.Assert_Files_Equal (Filename1 => Testfile, Filename2 => Reffile), Message => "append does not work"); Ada.Directories.Delete_File (Name => Testfile); end Append; Overwrite : declare F1 : File_Descriptor.Instance; F2 : File_Descriptor.Instance; Testfile : constant String := "./data/Log_Overwrite_Fd"; Reffile : constant String := "./data/Log_Overwrite_Fd.ref"; begin F1.Toggle_Write_Timestamp (State => False); F1.Set_Logfile (Path => Testfile); F1.Process (Request => Create (Message => "Facility1")); F1.Close_Logfile; F2.Toggle_Write_Timestamp (State => False); F2.Set_Logfile (Path => Testfile, Append => False); F2.Process (Request => Create (Message => "Facility2")); F2.Close_Logfile; Assert (Condition => Helpers.Assert_Files_Equal (Filename1 => Testfile, Filename2 => Reffile), Message => "overwrite does not work"); Ada.Directories.Delete_File (Name => Testfile); end Overwrite; end Verify_Append; ------------------------------------------------------------------------- procedure Write_Message_Fd is F : File_Descriptor.Instance; Testfile : constant String := "./data/Write_Message_Fd"; Reffile : constant String := "./data/Write_Message_Fd.ref"; begin -- We have to disable timestamps, since its changing all -- the time :) F.Toggle_Write_Timestamp (State => False); -- Open logfile, write test message. F.Set_Logfile (Path => Testfile); F.Process (Request => Create (Message => "This is a test log-message")); F.Close_Logfile; Assert (Condition => Helpers.Assert_Files_Equal (Filename1 => Reffile, Filename2 => Testfile), Message => "files not equal"); Ada.Directories.Delete_File (Name => Testfile); end Write_Message_Fd; end Facility_Tests.FD; libalog-0.5.0/tests/facility_tests-fd.ads000066400000000000000000000034361241767602000204100ustar00rootroot00000000000000-- -- Copyright (c) 2008-2009, -- Reto Buerki, Adrian-Ken Rueegsegger -- -- This file is part of Alog. -- -- Alog is free software; you can redistribute it and/or modify -- it under the terms of the GNU Lesser General Public License as published -- by the Free Software Foundation; either version 2.1 of the License, or -- (at your option) any later version. -- -- Alog is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public License -- along with Alog; if not, write to the Free Software -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, -- MA 02110-1301 USA -- with Ahven.Framework; package Facility_Tests.FD is type Testcase is new Ahven.Framework.Test_Case with null record; procedure Initialize (T : in out Testcase); -- Initialize testcase. procedure Set_Valid_Logfile_Fd; -- Set correct Fd test. procedure Set_Invalid_Logfile_Fd; -- Set illegal Fd test. procedure Write_Message_Fd; -- Test message writing. procedure Teardown_Fd; -- Test Facility cleanup. procedure Toggle_Write_Timestamp_Fd; -- Test the timestamp enable/disable functionality. procedure Toggle_Write_Loglevel_Fd; -- Test the loglevel enable/disable functionality. procedure Toggle_Write_Source_Fd; -- Test the source writing enable/disable functionality. procedure Trim_Loglevels_Fd; -- Test alignment of loglevels. procedure Verify_Append; -- Test set logfile append behavior. procedure Dst_Loglevel_Handling; -- Verify destination loglevel handling. end Facility_Tests.FD; libalog-0.5.0/tests/facility_tests-syslog.adb000066400000000000000000000034351241767602000213150ustar00rootroot00000000000000-- -- Copyright (c) 2011, -- Reto Buerki, Adrian-Ken Rueegsegger -- -- This file is part of Alog. -- -- Alog is free software; you can redistribute it and/or modify -- it under the terms of the GNU Lesser General Public License as published -- by the Free Software Foundation; either version 2.1 of the License, or -- (at your option) any later version. -- -- Alog is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public License -- along with Alog; if not, write to the Free Software -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, -- MA 02110-1301 USA -- with Ahven; with Alog.Facilities.Syslog; package body Facility_Tests.Syslog is use Ahven; package FS renames Alog.Facilities.Syslog; ------------------------------------------------------------------------- procedure Initialize (T : in out Testcase) is begin T.Set_Name (Name => "Tests for syslog Facility"); T.Add_Test_Routine (Routine => Set_Syslog_Origin'Access, Name => "set/get origin"); end Initialize; ------------------------------------------------------------------------- procedure Set_Syslog_Origin is use type Alog.Facilities.Syslog.Syslog_Origin; F : FS.Instance; begin Assert (Condition => F.Get_Origin = FS.LOG_USER, Message => "Default origin not LOG_USER"); F.Set_Origin (Value => FS.LOG_MAIL); Assert (Condition => F.Get_Origin = FS.LOG_MAIL, Message => "Origin not LOG_MAIL"); end Set_Syslog_Origin; end Facility_Tests.Syslog; libalog-0.5.0/tests/facility_tests-syslog.ads000066400000000000000000000021631241767602000213330ustar00rootroot00000000000000-- -- Copyright (c) 2011, -- Reto Buerki, Adrian-Ken Rueegsegger -- -- This file is part of Alog. -- -- Alog is free software; you can redistribute it and/or modify -- it under the terms of the GNU Lesser General Public License as published -- by the Free Software Foundation; either version 2.1 of the License, or -- (at your option) any later version. -- -- Alog is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public License -- along with Alog; if not, write to the Free Software -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, -- MA 02110-1301 USA -- with Ahven.Framework; package Facility_Tests.Syslog is type Testcase is new Ahven.Framework.Test_Case with null record; procedure Initialize (T : in out Testcase); -- Initialize testcase. procedure Set_Syslog_Origin; -- Test syslog origin setter/getter. end Facility_Tests.Syslog; libalog-0.5.0/tests/facility_tests.adb000066400000000000000000000136471241767602000200050ustar00rootroot00000000000000-- -- Copyright (c) 2008-2009, -- Reto Buerki, Adrian-Ken Rueegsegger -- -- This file is part of Alog. -- -- Alog is free software; you can redistribute it and/or modify -- it under the terms of the GNU Lesser General Public License as published -- by the Free Software Foundation; either version 2.1 of the License, or -- (at your option) any later version. -- -- Alog is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public License -- along with Alog; if not, write to the Free Software -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, -- MA 02110-1301 USA -- with Ada.Calendar.Time_Zones; with Ahven; use Ahven; with Alog.Facilities.File_Descriptor; package body Facility_Tests is use Alog; use Alog.Facilities; ------------------------------------------------------------------------- procedure Initialize (T : in out Testcase) is begin T.Set_Name (Name => "Tests for Facilites"); T.Add_Test_Routine (Routine => Set_Name'Access, Name => "set facility name"); T.Add_Test_Routine (Routine => Toggle_Loglevel'Access, Name => "toggle loglevel"); T.Add_Test_Routine (Routine => Toggle_Timestamp'Access, Name => "toggle timestamp"); T.Add_Test_Routine (Routine => Toggle_UTC_Timestamp'Access, Name => "toggle UTC timestamp"); T.Add_Test_Routine (Routine => Toggle_Source'Access, Name => "toggle source writing"); T.Add_Test_Routine (Routine => Timestamp_Creation'Access, Name => "timestamp creation"); T.Add_Test_Routine (Routine => Timestamp_Format_Setter'Access, Name => "set timestamp format"); end Initialize; ------------------------------------------------------------------------- procedure Set_Name is F : File_Descriptor.Instance; Expected : constant String := "TEST"; begin F.Set_Name (Name => Expected); Assert (Condition => F.Get_Name = Expected, Message => "name not equal"); end Set_Name; ------------------------------------------------------------------------- procedure Timestamp_Creation is use Ada.Calendar; use Ada.Calendar.Time_Zones; F : File_Descriptor.Instance; Ref_Time : constant Time := Time_Of (Year => 2009, Month => 10, Day => 10, Seconds => 7255.0); Ref_Stamp : constant String := "Oct 10 2009 02:00:55"; -- Adding the UTC time offset to the reference time should lead to the -- same timestamp string when UTC timestamps are enabled since UTC time -- is timezone-dependent time minus the UTC offset at that given time. Ref_UTC_Time : constant Time := Ref_Time + Duration (UTC_Time_Offset (Ref_Time)) * 60; begin Assert (Condition => Ref_Stamp = F.Get_Timestamp (Time => Ref_Time), Message => "Timestamp mismatch"); F.Toggle_UTC_Timestamp (State => True); Assert (Condition => F.Get_Timestamp (Time => Ref_UTC_Time) = Ref_Stamp, Message => "UTC timestamp mismatch!"); end Timestamp_Creation; ------------------------------------------------------------------------- procedure Timestamp_Format_Setter is use Ada.Calendar; use Ada.Calendar.Time_Zones; F : File_Descriptor.Instance; Ref_Time : constant Time := Time_Of (Year => 2009, Month => 10, Day => 10, Seconds => 7255.0); begin F.Set_Timestamp_Format (Format => "%b %Y"); Assert (Condition => F.Get_Timestamp (Time => Ref_Time) = "Oct 2009", Message => "Timestamp mismatch"); begin F.Set_Timestamp_Format (Format => "a b c %"); Fail (Message => "Exception expected"); exception when Invalid_Timestamp_Format => null; end; end Timestamp_Format_Setter; ------------------------------------------------------------------------- procedure Toggle_Loglevel is F : File_Descriptor.Instance; begin Assert (Condition => not F.Is_Write_Loglevel, Message => "Loglevel writing is 'True' by default"); F.Toggle_Write_Loglevel (State => True); Assert (Condition => F.Is_Write_Loglevel, Message => "Loglevel writing not 'True'"); end Toggle_Loglevel; ------------------------------------------------------------------------- procedure Toggle_Source is F : File_Descriptor.Instance; begin Assert (Condition => F.Is_Write_Source, Message => "Source writing is 'False' by default"); F.Toggle_Write_Source (State => False); Assert (Condition => not F.Is_Write_Source, Message => "Source writing is still 'True'"); end Toggle_Source; ------------------------------------------------------------------------- procedure Toggle_Timestamp is F : File_Descriptor.Instance; begin Assert (Condition => F.Is_Write_Timestamp, Message => "Timestamp writing is 'False' by default"); F.Toggle_Write_Timestamp (State => False); Assert (Condition => not F.Is_Write_Timestamp, Message => "Timestamp writing not 'False'"); end Toggle_Timestamp; ------------------------------------------------------------------------- procedure Toggle_UTC_Timestamp is F : File_Descriptor.Instance; begin Assert (Condition => not F.Is_UTC_Timestamp, Message => "Default should be 'False'"); F.Toggle_UTC_Timestamp (State => True); Assert (Condition => F.Is_UTC_Timestamp, Message => "Expected 'True'"); end Toggle_UTC_Timestamp; end Facility_Tests; libalog-0.5.0/tests/facility_tests.ads000066400000000000000000000031351241767602000200150ustar00rootroot00000000000000-- -- Copyright (c) 2008-2009, -- Reto Buerki, Adrian-Ken Rueegsegger -- -- This file is part of Alog. -- -- Alog is free software; you can redistribute it and/or modify -- it under the terms of the GNU Lesser General Public License as published -- by the Free Software Foundation; either version 2.1 of the License, or -- (at your option) any later version. -- -- Alog is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public License -- along with Alog; if not, write to the Free Software -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, -- MA 02110-1301 USA -- with Ahven.Framework; -- Tests for Alog facility components. package Facility_Tests is type Testcase is new Ahven.Framework.Test_Case with null record; procedure Initialize (T : in out Testcase); -- Initialize testcase. procedure Set_Name; -- Set name of Facility test. procedure Toggle_Loglevel; -- Test loglevel-writing related procedures. procedure Toggle_Timestamp; -- Test timestamp-writing related procedures. procedure Toggle_UTC_Timestamp; -- Test enabling/disabling UTC timestamps. procedure Toggle_Source; -- Test enabling/disabling source writing. procedure Timestamp_Creation; -- Test timestamp string creation. procedure Timestamp_Format_Setter; -- Test setting of timestamp formats. end Facility_Tests; libalog-0.5.0/tests/helper_tests.adb000066400000000000000000000126251241767602000174530ustar00rootroot00000000000000-- -- Copyright (c) 2009, -- Reto Buerki, Adrian-Ken Rueegsegger -- -- This file is part of Alog. -- -- Alog is free software; you can redistribute it and/or modify -- it under the terms of the GNU Lesser General Public License as published -- by the Free Software Foundation; either version 2.1 of the License, or -- (at your option) any later version. -- -- Alog is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public License -- along with Alog; if not, write to the Free Software -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, -- MA 02110-1301 USA -- with Ahven; with Alog.Helpers; with Alog.Maps; package body Helper_Tests is use Ahven; use Alog; use Alog.Helpers; ------------------------------------------------------------------------- procedure Compare_Files is File1 : constant String := "./data/ref_file1"; File2 : constant String := "./data/ref_file2"; File3 : constant String := "./data/ref_file3"; File4 : constant String := "./data/ref_file4"; begin Assert (Condition => Assert_Files_Equal (Filename1 => File1, Filename2 => File2), Message => "files should be equal"); Assert (Condition => not Assert_Files_Equal (Filename1 => File1, Filename2 => File3), Message => "files should not be equal"); Assert (Condition => not Assert_Files_Equal (Filename1 => File1, Filename2 => File4), Message => "filesize should not be equal"); end Compare_Files; ------------------------------------------------------------------------- procedure Initialize (T : in out Testcase) is begin T.Set_Name (Name => "Tests for helpers"); T.Add_Test_Routine (Routine => Compare_Files'Access, Name => "test file equality helper"); T.Add_Test_Routine (Routine => Read_Config'Access, Name => "read loglevel config file"); T.Add_Test_Routine (Routine => Read_Config_Nodefault'Access, Name => "read config without default loglevel"); T.Add_Test_Routine (Routine => Read_Config_Invalid_Loglevel'Access, Name => "read config with invalid loglevel"); T.Add_Test_Routine (Routine => Read_Invalid_Config'Access, Name => "read invalid config"); end Initialize; ------------------------------------------------------------------------- procedure Read_Config is Config_File : constant String := "./data/Loglevel_Config.ref"; Default_Level : Log_Level := Debug; Ident_Map : Maps.Wildcard_Level_Map; begin Read_Loglevels (Filename => Config_File, Default_Level => Default_Level, Identifiers => Ident_Map); Assert (Condition => Default_Level = Info, Message => "default loglevel mismatch"); Assert (Condition => Ident_Map.Element (Key => "Foo.*") = Debug, Message => "Foo.* mismatch"); Assert (Condition => Ident_Map.Element (Key => "Foo.Bar") = Alert, Message => "Foo.Bar mismatch"); Assert (Condition => Ident_Map.Element (Key => "Foo.Foo") = Notice, Message => "Foo.Foo mismatch"); end Read_Config; ------------------------------------------------------------------------- procedure Read_Config_Invalid_Loglevel is Config_File : constant String := "./data/Loglevel_Config_Invalid1.ref"; Default_Level : Log_Level := Debug; Ident_Map : Maps.Wildcard_Level_Map; begin Read_Loglevels (Filename => Config_File, Default_Level => Default_Level, Identifiers => Ident_Map); Fail (Message => "expected Invalid_Config"); exception when Invalid_Config => null; end Read_Config_Invalid_Loglevel; ------------------------------------------------------------------------- procedure Read_Config_Nodefault is Config_File : constant String := "./data/Loglevel_Config_Nodef.ref"; Default_Level : Log_Level := Debug; Ident_Map : Maps.Wildcard_Level_Map; begin Read_Loglevels (Filename => Config_File, Default_Level => Default_Level, Identifiers => Ident_Map); Assert (Condition => Default_Level = Debug, Message => "default loglevel changed"); Assert (Condition => Ident_Map.Element (Key => "Foo.*") = Debug, Message => "Foo.* mismatch"); end Read_Config_Nodefault; ------------------------------------------------------------------------- procedure Read_Invalid_Config is Config_File : constant String := "./data/Loglevel_Config_Invalid2.ref"; Default_Level : Log_Level := Debug; Ident_Map : Maps.Wildcard_Level_Map; begin Read_Loglevels (Filename => Config_File, Default_Level => Default_Level, Identifiers => Ident_Map); Fail (Message => "expected Invalid_Config"); exception when Invalid_Config => null; end Read_Invalid_Config; end Helper_Tests; libalog-0.5.0/tests/helper_tests.ads000066400000000000000000000027511241767602000174730ustar00rootroot00000000000000-- -- Copyright (c) 2009, -- Reto Buerki, Adrian-Ken Rueegsegger -- -- This file is part of Alog. -- -- Alog is free software; you can redistribute it and/or modify -- it under the terms of the GNU Lesser General Public License as published -- by the Free Software Foundation; either version 2.1 of the License, or -- (at your option) any later version. -- -- Alog is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public License -- along with Alog; if not, write to the Free Software -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, -- MA 02110-1301 USA -- with Ahven.Framework; -- Tests for Alog helpers. package Helper_Tests is type Testcase is new Ahven.Framework.Test_Case with null record; procedure Initialize (T : in out Testcase); -- Initialize testcase. procedure Compare_Files; -- Verify Assert_Files_Equal helper function. procedure Read_Config; -- Verify configuration file loading. procedure Read_Config_Nodefault; -- Read a loglevel config file without default loglevel line. procedure Read_Config_Invalid_Loglevel; -- Try to read a loglevel config file with invalid loglevel. procedure Read_Invalid_Config; -- Try to read an invalid config file. end Helper_Tests; libalog-0.5.0/tests/log_request_tests.adb000066400000000000000000000052031241767602000205170ustar00rootroot00000000000000-- -- Copyright (c) 2009, -- Reto Buerki, Adrian-Ken Rueegsegger -- -- This file is part of Alog. -- -- Alog is free software; you can redistribute it and/or modify -- it under the terms of the GNU Lesser General Public License as published -- by the Free Software Foundation; either version 2.1 of the License, or -- (at your option) any later version. -- -- Alog is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public License -- along with Alog; if not, write to the Free Software -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, -- MA 02110-1301 USA -- with Ada.Task_Identification; with Ahven; use Ahven; with Alog.Log_Request; package body Log_Request_Tests is use Alog; ------------------------------------------------------------------------- procedure Initialize (T : in out Testcase) is begin T.Set_Name (Name => "Tests for log requests"); T.Add_Test_Routine (Routine => Log_Request_Getter'Access, Name => "log request getters"); end Initialize; ------------------------------------------------------------------------- procedure Log_Request_Getter is use Ada.Task_Identification; Request : Log_Request.Instance; Ref_ID : constant Task_Id := Current_Task; Ref_Src : constant String := "Foo"; Ref_Msg : constant String := "Some log message"; begin Assert (Condition => Request.Get_Caller_ID = Null_Task_Id, Message => "Default ID not Null_Task_Id"); Assert (Condition => Request.Get_Log_Level = Info, Message => "Default log level not INFO"); Assert (Condition => Request.Get_Message = "", Message => "Default message not empty"); Request := Log_Request.Create (ID => Ref_ID, Source => Ref_Src, Level => Notice, Message => Ref_Msg); Assert (Condition => Request.Get_Caller_ID = Ref_ID, Message => "Caller ID mismatch"); Assert (Condition => Request.Get_Source = Ref_Src, Message => "Source mismatch"); Assert (Condition => Request.Get_Log_Level = Notice, Message => "Log level mismatch"); Assert (Condition => Request.Get_Message = Ref_Msg, Message => "Message mismatch"); end Log_Request_Getter; end Log_Request_Tests; libalog-0.5.0/tests/log_request_tests.ads000066400000000000000000000022161241767602000205410ustar00rootroot00000000000000-- -- Copyright (c) 2009, -- Reto Buerki, Adrian-Ken Rueegsegger -- -- This file is part of Alog. -- -- Alog is free software; you can redistribute it and/or modify -- it under the terms of the GNU Lesser General Public License as published -- by the Free Software Foundation; either version 2.1 of the License, or -- (at your option) any later version. -- -- Alog is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public License -- along with Alog; if not, write to the Free Software -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, -- MA 02110-1301 USA -- with Ahven.Framework; -- Tests for Alog log requests. package Log_Request_Tests is type Testcase is new Ahven.Framework.Test_Case with null record; procedure Initialize (T : in out Testcase); -- Initialize testcase. procedure Log_Request_Getter; -- Test log request getter functions. end Log_Request_Tests; libalog-0.5.0/tests/logger_tests.adb000066400000000000000000000524441241767602000174560ustar00rootroot00000000000000-- -- Copyright (c) 2008-2009, -- Reto Buerki, Adrian-Ken Rueegsegger -- -- This file is part of Alog. -- -- Alog is free software; you can redistribute it and/or modify -- it under the terms of the GNU Lesser General Public License as published -- by the Free Software Foundation; either version 2.1 of the License, or -- (at your option) any later version. -- -- Alog is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public License -- along with Alog; if not, write to the Free Software -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, -- MA 02110-1301 USA -- with Ada.Directories; with Ahven; with Alog.Helpers; with Alog.Logger; with Alog.Facilities.File_Descriptor; with Alog.Facilities.Syslog; with Alog.Transforms.Casing; package body Logger_Tests is use Ahven; use Alog; ------------------------------------------------------------------------- procedure Attach_Facility is Log : Logger.Instance (Init => False); Facility : constant Facilities.Handle := new Facilities.File_Descriptor.Instance; procedure Check_Facility (Facility_Handle : Facilities.Handle); -- Verify that facility with given name is present in the logger. procedure Check_Facility (Facility_Handle : Facilities.Handle) is use type Facilities.Handle; begin Assert (Condition => Facility_Handle = Facility, Message => "facility mismatch"); end Check_Facility; begin Assert (Condition => Log.Facility_Count = 0, Message => "facility count not 0"); begin Log.Update (Name => Facility.Get_Name, Process => Check_Facility'Access); exception when Logger.Facility_Not_Found => null; end; Log.Attach_Facility (Facility => Facility); Assert (Condition => Log.Facility_Count = 1, Message => "could not attach facility"); Log.Update (Name => Facility.Get_Name, Process => Check_Facility'Access); begin Log.Attach_Facility (Facility => Facility); Fail (Message => "attached duplicate facility"); exception when Logger.Facility_Already_Present => null; end; end Attach_Facility; ------------------------------------------------------------------------- procedure Attach_Transform is Log : Logger.Instance (Init => False); Transform : constant Transforms.Handle := new Transforms.Casing.Instance; procedure Check_Transform (Transform_Handle : Transforms.Handle); -- Verify that transformy with given name is present in the logger. procedure Check_Transform (Transform_Handle : Transforms.Handle) is use type Transforms.Handle; begin Assert (Condition => Transform_Handle = Transform, Message => "transform mismatch"); end Check_Transform; begin Assert (Condition => Log.Transform_Count = 0, Message => "transform count not 0"); begin Log.Update (Name => Transform.Get_Name, Process => Check_Transform'Access); exception when Logger.Transform_Not_Found => null; end; Log.Attach_Transform (Transform => Transform); Assert (Condition => Log.Transform_Count = 1, Message => "could not attach transform"); Log.Update (Name => Transform.Get_Name, Process => Check_Transform'Access); begin Log.Attach_Transform (Transform => Transform); Fail (Message => "attached duplicate transform"); exception when Logger.Transform_Already_Present => null; end; end Attach_Transform; ------------------------------------------------------------------------- procedure Clear_A_Logger is Log : Logger.Instance (Init => False); Facility : constant Facilities.Handle := new Facilities.File_Descriptor.Instance; Transform : constant Transforms.Handle := new Transforms.Casing.Instance; begin Log.Attach_Facility (Facility => Facility); Assert (Condition => Log.Facility_Count = 1, Message => "could not attach facility"); Log.Attach_Transform (Transform => Transform); Assert (Condition => Log.Transform_Count = 1, Message => "could not attach transform"); Log.Clear; Assert (Condition => Log.Facility_Count = 0, Message => "facility count is not 0"); Assert (Condition => Log.Transform_Count = 0, Message => "transform count is not 0"); end Clear_A_Logger; ------------------------------------------------------------------------- procedure Default_Facility_Handling is Logger1 : Logger.Instance (Init => False); Logger2 : Logger.Instance (Init => True); begin Logger1.Attach_Default_Facility; Assert (Condition => Logger1.Facility_Count = 1, Message => "Unable to attach facility"); Logger1.Attach_Default_Facility; Assert (Condition => Logger1.Facility_Count = 1, Message => "Attached facility twice"); Logger1.Log_Message (Level => Debug, Msg => "Testing default logger"); Logger1.Detach_Default_Facility; Assert (Condition => Logger1.Facility_Count = 0, Message => "Unable to detach facility"); Logger2.Attach_Default_Facility; Assert (Condition => Logger2.Facility_Count = 1, Message => "Attached facility to initialized logger"); Logger2.Detach_Default_Facility; Assert (Condition => Logger2.Facility_Count = 0, Message => "Unable to detach facility from logger"); end Default_Facility_Handling; ------------------------------------------------------------------------- procedure Detach_Facility_Instance is Log : Logger.Instance (Init => False); Facility : constant Facilities.Handle := new Facilities.Syslog.Instance; begin Facility.Set_Name ("Syslog_Facility"); Log.Attach_Facility (Facility => Facility); Assert (Condition => Log.Facility_Count = 1, Message => "could not attach"); Log.Detach_Facility (Name => Facility.Get_Name); Assert (Condition => Log.Facility_Count = 0, Message => "could not detach"); end Detach_Facility_Instance; ------------------------------------------------------------------------- procedure Detach_Facility_Unattached is Log : Logger.Instance (Init => False); Facility : Facilities.Handle := new Facilities.Syslog.Instance; begin Facility.Set_Name ("Syslog_Facility"); Log.Detach_Facility (Name => Facility.Get_Name); Fail (Message => "could detach unattached facility"); exception when Logger.Facility_Not_Found => -- Free not attached facility, this is not done by the logger (since -- it was never attached). Alog.Logger.Free (Facility); -- Test passed. end Detach_Facility_Unattached; ------------------------------------------------------------------------- procedure Detach_Transform_Instance is Log : Logger.Instance (Init => False); Transform : constant Transforms.Handle := new Transforms.Casing.Instance; begin Transform.Set_Name ("Casing_Transform"); Log.Attach_Transform (Transform => Transform); Assert (Condition => Log.Transform_Count = 1, Message => "could not attach"); Log.Detach_Transform (Name => Transform.Get_Name); Assert (Condition => Log.Transform_Count = 0, Message => "could not detach"); end Detach_Transform_Instance; ------------------------------------------------------------------------- procedure Detach_Transform_Unattached is Log : Logger.Instance (Init => False); Transform : Transforms.Handle := new Transforms.Casing.Instance; begin Transform.Set_Name ("Casing_Transform"); Log.Detach_Transform (Name => Transform.Get_Name); Fail (Message => "could detach unattached transform"); exception when Logger.Transform_Not_Found => -- Free not attached Transform, this is not done by the logger (since -- it was never attached). Alog.Logger.Free (Transform); -- Test passed. end Detach_Transform_Unattached; ------------------------------------------------------------------------- procedure Initialize (T : in out Testcase) is begin T.Set_Name (Name => "Tests for Logger"); T.Add_Test_Routine (Routine => Attach_Facility'Access, Name => "attach a facility"); T.Add_Test_Routine (Routine => Update_Facility'Access, Name => "update a facility"); T.Add_Test_Routine (Routine => Detach_Facility_Instance'Access, Name => "detach facility"); T.Add_Test_Routine (Routine => Detach_Facility_Unattached'Access, Name => "detach not attached facility"); T.Add_Test_Routine (Routine => Attach_Transform'Access, Name => "attach a transform"); T.Add_Test_Routine (Routine => Update_Transform'Access, Name => "update a transform"); T.Add_Test_Routine (Routine => Detach_Transform_Instance'Access, Name => "detach transform"); T.Add_Test_Routine (Routine => Detach_Transform_Unattached'Access, Name => "detach not attached transform"); T.Add_Test_Routine (Routine => Clear_A_Logger'Access, Name => "clear logger"); T.Add_Test_Routine (Routine => Log_One_FD_Facility'Access, Name => "log to one fd facility"); T.Add_Test_Routine (Routine => Log_Multiple_FD_Facilities'Access, Name => "log to multiple fd facilities"); T.Add_Test_Routine (Routine => Log_FD_Facility_with_Transform'Access, Name => "log to fd facility with lowercase transform"); T.Add_Test_Routine (Routine => Verify_Logger_Initialization'Access, Name => "logger initialization behavior"); T.Add_Test_Routine (Routine => Default_Facility_Handling'Access, Name => "default facility handling"); T.Add_Test_Routine (Routine => Source_Based_Logging'Access, Name => "source based logging"); T.Add_Test_Routine (Routine => Loglevel_Handling'Access, Name => "loglevel handling"); end Initialize; ------------------------------------------------------------------------- procedure Log_FD_Facility_with_Transform is Log : Logger.Instance (Init => False); Facility : constant Facilities.Handle := new Facilities.File_Descriptor.Instance; Transform : constant Transforms.Handle := new Transforms.Casing.Instance; Testfile : constant String := "./data/Log_FD_Facility_Lowercase"; Reffile : constant String := "./data/Log_FD_Facility_Lowercase.ref"; begin Facility.Toggle_Write_Timestamp (State => False); -- Call facility fd specific procedures. Facilities.File_Descriptor.Handle (Facility).Set_Logfile (Testfile); -- Call casing transform specific procedures. Transforms.Casing.Handle (Transform).Set_Name ("lowercase"); Log.Attach_Facility (Facility => Facility); Log.Attach_Transform (Transform => Transform); Log.Log_Message (Level => Debug, Msg => "Logger Test Message, " & "FD Facility With Lowercase Transform"); Log.Clear; Assert (Condition => Helpers.Assert_Files_Equal (Filename1 => Reffile, Filename2 => Testfile), Message => "files not equal"); Ada.Directories.Delete_File (Name => Testfile); end Log_FD_Facility_with_Transform; ------------------------------------------------------------------------- procedure Log_Multiple_FD_Facilities is Log : Logger.Instance (Init => False); Facility1 : constant Facilities.Handle := new Facilities.File_Descriptor.Instance; Testfile1 : constant String := "./data/Log_Multiple_FD_Facilities1"; Reffile : constant String := "./data/Log_Multiple_FD_Facilities.ref"; Facility2 : constant Facilities.Handle := new Facilities.File_Descriptor.Instance; Testfile2 : constant String := "./data/Log_Multiple_FD_Facilities2"; begin -- Set facility parameters. Facility1.Set_Name (Name => "Facility1"); Facility1.Toggle_Write_Timestamp (State => False); Facility1.Toggle_Write_Loglevel (State => True); Facility2.Set_Name (Name => "Facility2"); Facility2.Toggle_Write_Timestamp (State => False); Facility2.Toggle_Write_Loglevel (State => True); -- Call facility fd specific procedures. Facilities.File_Descriptor.Handle (Facility1).Set_Logfile (Testfile1); Facilities.File_Descriptor.Handle (Facility2).Set_Logfile (Testfile2); -- Attach both facilities to logger instance. Log.Attach_Facility (Facility => Facility1); Log.Attach_Facility (Facility => Facility2); -- Log two messages. Log.Log_Message (Level => Debug, Msg => "Logger testmessage, multiple facilities"); Log.Log_Message (Level => Info, Msg => "Logger testmessage, multiple facilities"); Log.Clear; Assert (Condition => Helpers.Assert_Files_Equal (Filename1 => Reffile, Filename2 => Testfile1), Message => "file1 not equal"); Assert (Condition => Helpers.Assert_Files_Equal (Filename1 => Reffile, Filename2 => Testfile2), Message => "file2 not equal"); Ada.Directories.Delete_File (Name => Testfile1); Ada.Directories.Delete_File (Name => Testfile2); end Log_Multiple_FD_Facilities; ------------------------------------------------------------------------- procedure Log_One_FD_Facility is Log : Logger.Instance (Init => False); Facility : constant Facilities.Handle := new Facilities.File_Descriptor.Instance; Testfile : constant String := "./data/Log_One_FD_Facility"; Reffile : constant String := "./data/Log_One_FD_Facility.ref"; begin Facility.Toggle_Write_Timestamp (State => False); -- Call facility fd specific procedures. Facilities.File_Descriptor.Handle (Facility).Set_Logfile (Testfile); Log.Attach_Facility (Facility => Facility); Log.Log_Message (Level => Debug, Msg => "Logger testmessage, one fd facility"); Log.Clear; Assert (Condition => Helpers.Assert_Files_Equal (Filename1 => Reffile, Filename2 => Testfile), Message => "files not equal"); Ada.Directories.Delete_File (Name => Testfile); end Log_One_FD_Facility; ------------------------------------------------------------------------- procedure Loglevel_Handling is Log : Logger.Instance (Init => False); Facility : constant Facilities.Handle := new Facilities.File_Descriptor.Instance; Testfile : constant String := "./data/Logger_Loglevel"; Reffile : constant String := "./data/Logger_Loglevel.ref"; begin Facility.Toggle_Write_Timestamp (State => False); Facility.Toggle_Write_Loglevel (State => True); -- Call facility fd specific procedures. Facilities.File_Descriptor.Handle (Facility).Set_Logfile (Testfile); Log.Attach_Facility (Facility => Facility); Log.Log_Message (Level => Debug, Msg => "Debug message (logged)"); Log.Log_Message (Level => Notice, Msg => "Notice message (logged)"); Log.Clear; Assert (Condition => Helpers.Assert_Files_Equal (Filename1 => Reffile, Filename2 => Testfile), Message => "Files not equal"); Ada.Directories.Delete_File (Name => Testfile); end Loglevel_Handling; ------------------------------------------------------------------------- procedure Source_Based_Logging is Log : Logger.Instance (Init => False); Facility : constant Facilities.Handle := new Facilities.File_Descriptor.Instance; Testfile : constant String := "./data/Log_Source_Loglevel"; Reffile : constant String := "./data/Log_Source_Loglevel.ref"; begin Facility.Toggle_Write_Timestamp (State => False); Facility.Toggle_Write_Loglevel (State => True); Facilities.File_Descriptor.Handle (Facility).Set_Logfile (Testfile); Log.Attach_Facility (Facility => Facility); Log.Log_Message (Source => "Test", Level => Info, Msg => "Source test (logged)"); Log.Log_Message (Level => Debug, Msg => "Default source (logged)"); Log.Log_Message (Source => "Unknown", Level => Notice, Msg => "Unknown source (logged)"); Log.Clear; Assert (Condition => Helpers.Assert_Files_Equal (Filename1 => Reffile, Filename2 => Testfile), Message => "Files not equal"); Ada.Directories.Delete_File (Name => Testfile); end Source_Based_Logging; ------------------------------------------------------------------------- procedure Update_Facility is procedure Do_Nothing (Facility_Handle : Facilities.Handle) is null; -- Just do nothing. Log : Logger.Instance (Init => False); begin begin Log.Update (Name => "Nonexistent", Process => Do_Nothing'Access); Fail (Message => "Expected Facility_Not_Found"); exception when Logger.Facility_Not_Found => null; end; declare Facility : constant Facilities.Handle := new Facilities.File_Descriptor.Instance; Facility_Name : constant String := "Test_Facility"; procedure Update_Facility (Facility_Handle : Facilities.Handle); -- Set the facility's write timestamp flag to True. procedure Update_Facility (Facility_Handle : Facilities.Handle) is begin Facility_Handle.Toggle_Write_Timestamp (State => True); end Update_Facility; begin Facility.Set_Name (Name => Facility_Name); Facility.Toggle_Write_Timestamp (State => False); Assert (Condition => not Facility.Is_Write_Timestamp, Message => "Could not disable Timestamp"); Log.Attach_Facility (Facility => Facility); Log.Update (Name => Facility_Name, Process => Update_Facility'Access); Assert (Condition => Facility.Is_Write_Timestamp, Message => "Update failed"); end; end Update_Facility; ------------------------------------------------------------------------- procedure Update_Transform is procedure Do_Nothing (Transform_Handle : Transforms.Handle) is null; -- Just do nothing. Log : Logger.Instance (Init => False); begin begin Log.Update (Name => "Nonexistent", Process => Do_Nothing'Access); Fail (Message => "Expected Transform_Not_Found"); exception when Logger.Transform_Not_Found => null; end; declare Transform : constant Transforms.Handle := new Transforms.Casing.Instance; Transform_Name : constant String := "Test_Transform"; Suffix : constant String := "_Updated"; procedure Update_Transform (Transform_Handle : Transforms.Handle); -- Set the transform's name to a test string. procedure Update_Transform (Transform_Handle : Transforms.Handle) is begin Transform_Handle.Set_Name (Name => Transform_Name & Suffix); end Update_Transform; begin Transform.Set_Name (Name => Transform_Name); Assert (Condition => Transform.Get_Name = Transform_Name, Message => "Transform name mismatch"); Log.Attach_Transform (Transform => Transform); Log.Update (Name => Transform_Name, Process => Update_Transform'Access); Assert (Condition => Transform.Get_Name = Transform_Name & Suffix, Message => "Transform update failed"); end; end Update_Transform; ------------------------------------------------------------------------- procedure Verify_Logger_Initialization is Logger1 : Logger.Instance (Init => False); Logger2 : Logger.Instance (Init => True); begin Assert (Condition => Logger1.Facility_Count = 0, Message => "logger1 not empty"); Assert (Condition => Logger2.Facility_Count = 1, Message => "logger2 empty"); end Verify_Logger_Initialization; end Logger_Tests; libalog-0.5.0/tests/logger_tests.ads000066400000000000000000000045711241767602000174750ustar00rootroot00000000000000-- -- Copyright (c) 2008-2009, -- Reto Buerki, Adrian-Ken Rueegsegger -- -- This file is part of Alog. -- -- Alog is free software; you can redistribute it and/or modify -- it under the terms of the GNU Lesser General Public License as published -- by the Free Software Foundation; either version 2.1 of the License, or -- (at your option) any later version. -- -- Alog is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public License -- along with Alog; if not, write to the Free Software -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, -- MA 02110-1301 USA -- with Ahven.Framework; -- Tests for Alog logger component. package Logger_Tests is type Testcase is new Ahven.Framework.Test_Case with null record; procedure Initialize (T : in out Testcase); -- Initialize testcase. procedure Attach_Facility; -- Test Facility attaching. procedure Update_Facility; -- Test Facility update operation. procedure Detach_Facility_Instance; -- Test Facility detaching by name. procedure Detach_Facility_Unattached; -- Test Facility detaching with a un-attached instance -- (should fail). procedure Attach_Transform; -- Test Transform attaching. procedure Update_Transform; -- Test Transform update operation. procedure Detach_Transform_Instance; -- Test Transform detaching by name. procedure Detach_Transform_Unattached; -- Test Transform detaching with un-attached instance procedure Clear_A_Logger; -- Test Logger cleanup. procedure Log_One_FD_Facility; -- Test logging to one fd based facility. procedure Log_Multiple_FD_Facilities; -- Test logging to multiple fd based facilities. procedure Log_FD_Facility_with_Transform; -- Test logging to fd based facility with lowercase transform. procedure Verify_Logger_Initialization; -- Test logger instance initialization behavior. procedure Default_Facility_Handling; -- Test attaching/detaching of default facility. procedure Source_Based_Logging; -- Test per-source loglevel handling. procedure Loglevel_Handling; -- Test loglevel handling. end Logger_Tests; libalog-0.5.0/tests/maps_tests.adb000066400000000000000000000126451241767602000171360ustar00rootroot00000000000000-- -- Copyright (c) 2009, -- Reto Buerki, Adrian-Ken Rueegsegger -- -- This file is part of Alog. -- -- Alog is free software; you can redistribute it and/or modify -- it under the terms of the GNU Lesser General Public License as published -- by the Free Software Foundation; either version 2.1 of the License, or -- (at your option) any later version. -- -- Alog is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public License -- along with Alog; if not, write to the Free Software -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, -- MA 02110-1301 USA -- with Ahven; use Ahven; with Alog.Maps; package body Maps_Tests is use Alog; ------------------------------------------------------------------------- procedure Clear_Map is Map : Maps.Wildcard_Level_Map; begin Map.Insert (Key => "Foo", Item => Debug); Map.Insert (Key => "Bar", Item => Warning); Assert (Condition => Map.Length = 2, Message => "Count not 2"); Map.Clear; Assert (Condition => Map.Length = 0, Message => "Count not 0"); end Clear_Map; ------------------------------------------------------------------------- procedure Initialize (T : in out Testcase) is begin T.Set_Name (Name => "Tests for maps"); T.Add_Test_Routine (Routine => Insert_Elements'Access, Name => "Insert elements"); T.Add_Test_Routine (Routine => Update_Element'Access, Name => "Update element"); T.Add_Test_Routine (Routine => Wildcard_Lookup'Access, Name => "Wildcard lookup"); end Initialize; ------------------------------------------------------------------------- procedure Insert_Elements is use type Maps.Cursor; Map : Maps.Wildcard_Level_Map; begin Map.Insert (Key => "Foo", Item => Debug); Assert (Condition => Map.Length = 1, Message => "Count not 1"); Assert (Condition => Map.Element (Key => "Foo") = Debug, Message => "Loglevel mismatch for key Foo"); declare Position : Maps.Cursor; begin Position := Map.Find (Key => "Foo"); Assert (Condition => Position /= Maps.No_Element, Message => "No element for key Foo"); Assert (Condition => Maps.Element (Position => Position) = Debug, Message => "Loglevel mismatch for position"); end; declare Position : Maps.Cursor; begin Position := Map.Find (Key => "Bar"); Assert (Condition => Position = Maps.No_Element, Message => "Found element for nonexistent key"); end; declare Level : Log_Level; pragma Unreferenced (Level); begin Level := Maps.Element (Position => Maps.No_Element); Fail (Message => "Expected constraint error"); exception when Constraint_Error => null; end; end Insert_Elements; ------------------------------------------------------------------------- procedure Update_Element is Map : Maps.Wildcard_Level_Map; begin Map.Insert (Key => "Foo", Item => Debug); Assert (Condition => Map.Element (Key => "Foo") = Debug, Message => "Loglevel mismatch"); Map.Insert (Key => "Foo", Item => Error); Assert (Condition => Map.Element (Key => "Foo") = Error, Message => "Update failed"); end Update_Element; ------------------------------------------------------------------------- procedure Wildcard_Lookup is Map : Maps.Wildcard_Level_Map; begin Map.Insert (Key => "Foo.*", Item => Notice); Map.Insert (Key => "Foo.Bar", Item => Warning); declare Position : Maps.Cursor; begin Position := Map.Lookup (Key => "Foo"); Assert (Condition => Maps.Element (Position => Position) = Notice, Message => "Loglevel for Foo not notice"); end; declare Position : Maps.Cursor; begin Position := Map.Lookup (Key => "Foo.Bar"); Assert (Condition => Maps.Element (Position => Position) = Warning, Message => "Loglevel for Foo.Bar not warning"); end; declare Position : Maps.Cursor; begin Position := Map.Lookup (Key => "Foo.Foo"); Assert (Condition => Maps.Element (Position => Position) = Notice, Message => "Loglevel for Foo.Foo not notice"); end; declare Position : Maps.Cursor; begin Position := Map.Lookup (Key => "Foo.Bar.Foo"); Assert (Condition => Maps.Element (Position => Position) = Notice, Message => "Loglevel for Foo.Bar.Foo not notice"); end; declare use type Maps.Cursor; Position : Maps.Cursor; begin Position := Map.Lookup (Key => "Bar.Bar"); Assert (Condition => Position = Maps.No_Element, Message => "No_Element expected"); end; end Wildcard_Lookup; end Maps_Tests; libalog-0.5.0/tests/maps_tests.ads000066400000000000000000000025131241767602000171500ustar00rootroot00000000000000-- -- Copyright (c) 2009, -- Reto Buerki, Adrian-Ken Rueegsegger -- -- This file is part of Alog. -- -- Alog is free software; you can redistribute it and/or modify -- it under the terms of the GNU Lesser General Public License as published -- by the Free Software Foundation; either version 2.1 of the License, or -- (at your option) any later version. -- -- Alog is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public License -- along with Alog; if not, write to the Free Software -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, -- MA 02110-1301 USA -- with Ahven.Framework; -- Tests for Alog map data structures. package Maps_Tests is type Testcase is new Ahven.Framework.Test_Case with null record; procedure Initialize (T : in out Testcase); -- Initialize testcase. procedure Insert_Elements; -- Insert and get elements into/from a wildcard map. procedure Update_Element; -- Update a wildcard map element. procedure Wildcard_Lookup; -- Verify wildcard lookup. procedure Clear_Map; -- Clear a wildcard map. end Maps_Tests; libalog-0.5.0/tests/policy_tests.adb000066400000000000000000000173621241767602000174760ustar00rootroot00000000000000-- -- Copyright (c) 2009, -- Reto Buerki, Adrian-Ken Rueegsegger -- -- This file is part of Alog. -- -- Alog is free software; you can redistribute it and/or modify -- it under the terms of the GNU Lesser General Public License as published -- by the Free Software Foundation; either version 2.1 of the License, or -- (at your option) any later version. -- -- Alog is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public License -- along with Alog; if not, write to the Free Software -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, -- MA 02110-1301 USA -- with Ahven; with Alog.Maps; with Alog.Policy_DB; package body Policy_Tests is use Ahven; use Alog; package DB renames Alog.Policy_DB; ------------------------------------------------------------------------- procedure Default_Loglevel_Handling is Before : constant Log_Level := DB.Get_Default_Loglevel; New_Level : constant Log_Level := Critical; begin DB.Set_Default_Loglevel (Level => New_Level); Assert (Condition => DB.Get_Default_Loglevel = New_Level, Message => "Default level mismatch"); DB.Set_Default_Loglevel (Level => Before); end Default_Loglevel_Handling; ------------------------------------------------------------------------- procedure Finalize (T : in out Testcase) is pragma Unreferenced (T); begin DB.Reset; end Finalize; ------------------------------------------------------------------------- procedure Ident_Loglevel_Handling is begin DB.Set_Loglevel (Identifier => "Foo", Level => Info); Assert (Condition => DB.Get_Loglevel (Identifier => "Foo") = Info, Message => "Ident loglevel mismatch"); DB.Set_Loglevel (Identifier => "Foo", Level => Error); Assert (Condition => DB.Get_Loglevel (Identifier => "Foo") = Error, Message => "Unable to update identifier loglevel"); declare Level : Log_Level; pragma Unreferenced (Level); begin Level := DB.Get_Loglevel (Identifier => "Bar"); Fail (Message => "Expected No_Ident_Loglevel"); exception when DB.No_Ident_Loglevel => null; end; end Ident_Loglevel_Handling; ------------------------------------------------------------------------- procedure Initialize (T : in out Testcase) is begin T.Set_Name (Name => "Tests for the logging policy database"); T.Add_Test_Routine (Routine => Reset_Policy_DB'Access, Name => "reset policy database"); T.Add_Test_Routine (Routine => Default_Loglevel_Handling'Access, Name => "default loglevel handling"); T.Add_Test_Routine (Routine => Ident_Loglevel_Handling'Access, Name => "identifier based loglevel handling"); T.Add_Test_Routine (Routine => Set_Identifier_Map'Access, Name => "set identifier loglevel map"); T.Add_Test_Routine (Routine => Verify_Accept_Src'Access, Name => "accept source"); T.Add_Test_Routine (Routine => Verify_Accept_Dst'Access, Name => "accept destination"); T.Add_Test_Routine (Routine => Lookup_Ident'Access, Name => "lookup identifier"); end Initialize; ------------------------------------------------------------------------- procedure Lookup_Ident is begin DB.Set_Default_Loglevel (Level => Error); DB.Set_Loglevel (Identifier => "Lookup.*", Level => Warning); Assert (Condition => DB.Lookup (Identifier => "Lookup") = Warning, Message => "Lookup mismatch"); Assert (Condition => DB.Lookup (Identifier => "Nonexistent") = Error, Message => "Nonexistent mismatch"); end Lookup_Ident; ------------------------------------------------------------------------- procedure Reset_Policy_DB is begin DB.Set_Default_Loglevel (Level => Error); DB.Set_Loglevel (Identifier => "Foo", Level => Warning); DB.Reset; Assert (Condition => DB.Get_Default_Loglevel = DB.Alog_Default_Level, Message => "Default loglevel mismatch"); declare Src_Level : Log_Level; pragma Unreferenced (Src_Level); begin Src_Level := DB.Get_Loglevel (Identifier => "Foo"); Fail (Message => "Src levels not reset"); exception when DB.No_Ident_Loglevel => null; end; end Reset_Policy_DB; ------------------------------------------------------------------------- procedure Set_Identifier_Map is Map : Maps.Wildcard_Level_Map; begin Map.Insert (Key => "Foo", Item => Notice); Map.Insert (Key => "Bar", Item => Warning); DB.Set_Loglevel (Identifiers => Map); Assert (Condition => DB.Get_Loglevel (Identifier => "Foo") = Notice, Message => "Foo identifier loglevel mismatch"); Assert (Condition => DB.Get_Loglevel (Identifier => "Bar") = Warning, Message => "Bar identifier loglevel mismatch"); end Set_Identifier_Map; ------------------------------------------------------------------------- procedure Verify_Accept_Dst is begin DB.Reset; -- Default loglevel should be ignored DB.Set_Default_Loglevel (Level => Info); Assert (Condition => DB.Accept_Dst (Identifier => "Foobar", Level => Debug), Message => "Debug not accepted"); DB.Set_Loglevel (Identifier => "Foo.*", Level => Error); Assert (Condition => not DB.Accept_Dst (Identifier => "Foo", Level => Debug), Message => "Dst debug accepted"); Assert (Condition => DB.Accept_Src (Identifier => "Foo", Level => Critical), Message => "Dst critical not accepted"); Assert (Condition => DB.Accept_Dst (Identifier => "Bar", Level => Info), Message => "Dst bar not accepted"); end Verify_Accept_Dst; ------------------------------------------------------------------------- procedure Verify_Accept_Src is begin DB.Reset; DB.Set_Default_Loglevel (Level => Info); Assert (Condition => not DB.Accept_Src (Level => Debug), Message => "Debug accepted"); Assert (Condition => DB.Accept_Src (Level => Warning), Message => "Warning not accepted"); DB.Set_Loglevel (Identifier => "Foo.*", Level => Error); Assert (Condition => not DB.Accept_Src (Identifier => "Foo", Level => Debug), Message => "Src debug accepted"); Assert (Condition => DB.Accept_Src (Identifier => "Foo", Level => Critical), Message => "Src critical not accepted"); Assert (Condition => DB.Accept_Src (Identifier => "Bar", Level => Info), Message => "Src bar not accepted"); DB.Set_Loglevel (Identifier => "Foobar.*", Level => Debug); Assert (Condition => DB.Accept_Src (Identifier => "Foobar", Level => Debug), Message => "Src foobar not accepted"); end Verify_Accept_Src; end Policy_Tests; libalog-0.5.0/tests/policy_tests.ads000066400000000000000000000033131241767602000175060ustar00rootroot00000000000000-- -- Copyright (c) 2009, -- Reto Buerki, Adrian-Ken Rueegsegger -- -- This file is part of Alog. -- -- Alog is free software; you can redistribute it and/or modify -- it under the terms of the GNU Lesser General Public License as published -- by the Free Software Foundation; either version 2.1 of the License, or -- (at your option) any later version. -- -- Alog is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public License -- along with Alog; if not, write to the Free Software -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, -- MA 02110-1301 USA -- with Ahven.Framework; -- Tests for the logging policy database package. package Policy_Tests is type Testcase is new Ahven.Framework.Test_Case with null record; procedure Initialize (T : in out Testcase); -- Initialize testcase. procedure Finalize (T : in out Testcase); -- Finalize testcase. procedure Reset_Policy_DB; -- Reset the policy database to initial state. procedure Default_Loglevel_Handling; -- Test default loglevel handling. procedure Ident_Loglevel_Handling; -- Test setting/getting of identifier based loglevels. procedure Set_Identifier_Map; -- Test setting of identifier based loglevels with wildcard map. procedure Verify_Accept_Src; -- Verify accept src behavior. procedure Verify_Accept_Dst; -- Verify accept dst behavior. procedure Lookup_Ident; -- Verify identifier lookup behavior. end Policy_Tests; libalog-0.5.0/tests/profiler.adb000066400000000000000000000023601241767602000165670ustar00rootroot00000000000000-- -- Copyright (c) 2009-2014, -- Reto Buerki, Adrian-Ken Rueegsegger -- -- This file is part of Alog. -- -- Alog is free software; you can redistribute it and/or modify -- it under the terms of the GNU Lesser General Public License as published -- by the Free Software Foundation; either version 2.1 of the License, or -- (at your option) any later version. -- -- Alog is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public License -- along with Alog; if not, write to the Free Software -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, -- MA 02110-1301 USA -- with Alog.Logger; with Alog.Policy_DB; procedure Profiler is use Alog; Log : Logger.Instance (Init => False); begin Policy_DB.Set_Loglevel (Identifier => "Foo.*", Level => Debug); for I in 1 .. 100000 loop Log.Log_Message (Source => "Foo.Foo.Foo.Foo", Level => Notice, Msg => "Test message"); end loop; end Profiler; libalog-0.5.0/tests/protected_container_tests.adb000066400000000000000000000112071241767602000222220ustar00rootroot00000000000000-- -- Copyright (c) 2009, -- Reto Buerki, Adrian-Ken Rueegsegger -- -- This file is part of Alog. -- -- Alog is free software; you can redistribute it and/or modify -- it under the terms of the GNU Lesser General Public License as published -- by the Free Software Foundation; either version 2.1 of the License, or -- (at your option) any later version. -- -- Alog is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public License -- along with Alog; if not, write to the Free Software -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, -- MA 02110-1301 USA -- with Ada.Task_Identification; with Ahven; use Ahven; with Alog.Log_Request; with Alog.Protected_Containers; package body Protected_Container_Tests is use Alog; ------------------------------------------------------------------------- procedure Initialize (T : in out Testcase) is begin T.Set_Name (Name => "Tests for protected containers"); T.Add_Test_Routine (Routine => Log_Request_List_Get_Put'Access, Name => "log request list get/put"); T.Add_Test_Routine (Routine => Log_Request_List_Clear'Access, Name => "log request list clear"); T.Add_Test_Routine (Routine => Log_Request_List_Done'Access, Name => "log request list done"); end Initialize; ------------------------------------------------------------------------- procedure Log_Request_List_Clear is use Ada.Task_Identification; R_List : Protected_Containers.Log_Request_List; Ref_Request : Log_Request.Instance; Ref_ID : constant Task_Id := Current_Task; Ref_Msg : constant String := "Some log message"; begin R_List.Clear; Ref_Request := Log_Request.Create (ID => Ref_ID, Level => Notice, Message => Ref_Msg); R_List.Put (Element => Ref_Request); Assert (Condition => R_List.Length = 1, Message => "Unable to insert request"); R_List.Clear; Assert (Condition => R_List.Length = 0, Message => "Unable to clear list"); end Log_Request_List_Clear; ------------------------------------------------------------------------- procedure Log_Request_List_Done is use Ada.Task_Identification; R_List : Protected_Containers.Log_Request_List; Ref_Request : Log_Request.Instance; Ref_ID : constant Task_Id := Current_Task; Ref_Msg : constant String := "Some log message"; begin Ref_Request := Log_Request.Create (ID => Ref_ID, Level => Notice, Message => Ref_Msg); Assert (Condition => R_List.Pending = 0, Message => "new list has pending requests"); R_List.Done; Assert (Condition => R_List.Pending = 0, Message => "done on new list failed"); R_List.Put (Element => Ref_Request); R_List.Get (Element => Ref_Request); Assert (Condition => R_List.Pending = 1, Message => "No request pending"); R_List.Done; Assert (Condition => R_List.Pending = 0, Message => "Still pending requests"); end Log_Request_List_Done; ------------------------------------------------------------------------- procedure Log_Request_List_Get_Put is use Ada.Task_Identification; R_List : Protected_Containers.Log_Request_List; Ref_Request : Log_Request.Instance; Ref_ID : constant Task_Id := Current_Task; Ref_Msg : constant String := "Some log message"; begin Ref_Request := Log_Request.Create (ID => Ref_ID, Level => Notice, Message => Ref_Msg); Assert (Condition => R_List.Length = 0, Message => "List not empty"); R_List.Put (Element => Ref_Request); Assert (Condition => R_List.Length = 1, Message => "Unable to insert request"); declare use type Alog.Log_Request.Instance; New_Request : Log_Request.Instance; begin R_List.Get (Element => New_Request); Assert (Condition => New_Request = Ref_Request, Message => "Request mismatch"); end; end Log_Request_List_Get_Put; end Protected_Container_Tests; libalog-0.5.0/tests/protected_container_tests.ads000066400000000000000000000025351241767602000222470ustar00rootroot00000000000000-- -- Copyright (c) 2009, -- Reto Buerki, Adrian-Ken Rueegsegger -- -- This file is part of Alog. -- -- Alog is free software; you can redistribute it and/or modify -- it under the terms of the GNU Lesser General Public License as published -- by the Free Software Foundation; either version 2.1 of the License, or -- (at your option) any later version. -- -- Alog is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public License -- along with Alog; if not, write to the Free Software -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, -- MA 02110-1301 USA -- with Ahven.Framework; -- Tests for Alog protected containers. package Protected_Container_Tests is type Testcase is new Ahven.Framework.Test_Case with null record; procedure Initialize (T : in out Testcase); -- Initialize testcase. procedure Log_Request_List_Get_Put; -- Test log request list get and put operations. procedure Log_Request_List_Clear; -- Test log request list clear operation. procedure Log_Request_List_Done; -- Test log request list Done operation. end Protected_Container_Tests; libalog-0.5.0/tests/tasked_logger_tests.adb000066400000000000000000000343461241767602000210120ustar00rootroot00000000000000-- -- Copyright (c) 2008-2011, -- Reto Buerki, Adrian-Ken Rueegsegger -- -- This file is part of Alog. -- -- Alog is free software; you can redistribute it and/or modify -- it under the terms of the GNU Lesser General Public License as published -- by the Free Software Foundation; either version 2.1 of the License, or -- (at your option) any later version. -- -- Alog is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public License -- along with Alog; if not, write to the Free Software -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, -- MA 02110-1301 USA -- with Ada.Exceptions; with Ada.Task_Identification; with Ahven; with Alog.Logger; with Alog.Tasked_Logger; with Alog.Facilities.File_Descriptor; with Alog.Facilities.Syslog; with Alog.Facilities.Mock; with Alog.Transforms.Casing; package body Tasked_Logger_Tests is use Ahven; use Alog; Counter : Natural := 0; pragma Atomic (Counter); procedure Do_Nothing (Facility_Handle : Facilities.Handle) is null; -- Just do nothing. procedure Inc_Counter (F_Handle : Facilities.Handle); -- Increment iterate counter. procedure Raise_Exception (F_Handle : Facilities.Handle); -- Raise constraint error. procedure Enable_Facility_Timestamp (Facility_Handle : Facilities.Handle); -- Enable write timestamp of facility. procedure Except_Handler (Except : Ada.Exceptions.Exception_Occurrence; Caller : Ada.Task_Identification.Task_Id); -- Exception handler used in tests. Just increments the atomic counter. ------------------------------------------------------------------------- procedure Attach_Facility is Log : Tasked_Logger.Instance (Init => False); Facility : constant Facilities.Handle := new Facilities.File_Descriptor.Instance; Count : Natural := Natural'Last; begin Log.Facility_Count (Count => Count); Assert (Condition => Count = 0, Message => "facility count not 0"); Log.Attach_Facility (Facility => Facility); Log.Facility_Count (Count => Count); Assert (Condition => Count = 1, Message => "could not attach facility"); begin Log.Attach_Facility (Facility => Facility); Fail (Message => "attached duplicate facility"); exception when Logger.Facility_Already_Present => null; end; end Attach_Facility; ------------------------------------------------------------------------- procedure Attach_Transform is Log : Tasked_Logger.Instance (Init => False); Transform : constant Transforms.Handle := new Transforms.Casing.Instance; Count : Natural := Natural'Last; begin Log.Transform_Count (Count => Count); Assert (Condition => Count = 0, Message => "transform count not 0"); Log.Attach_Transform (Transform => Transform); Log.Transform_Count (Count => Count); Assert (Condition => Count = 1, Message => "could not attach transform"); begin Log.Attach_Transform (Transform => Transform); Fail (Message => "attached duplicate transform"); exception when Logger.Transform_Already_Present => null; end; end Attach_Transform; ------------------------------------------------------------------------- procedure Default_Facility_Handling is Logger1 : Tasked_Logger.Instance (Init => False); Logger2 : Tasked_Logger.Instance (Init => True); F_Count : Natural := Natural'Last; begin Logger1.Attach_Default_Facility; Logger1.Facility_Count (Count => F_Count); Assert (Condition => F_Count = 1, Message => "Unable to attach facility"); Logger1.Attach_Default_Facility; Logger1.Facility_Count (Count => F_Count); Assert (Condition => F_Count = 1, Message => "Attached facility twice"); Logger1.Detach_Default_Facility; Logger1.Facility_Count (Count => F_Count); Assert (Condition => F_Count = 0, Message => "Unable to detach facility"); Logger2.Attach_Default_Facility; Logger2.Facility_Count (Count => F_Count); Assert (Condition => F_Count = 1, Message => "Attached facility to initialzed logger"); Logger2.Detach_Default_Facility; Logger2.Facility_Count (Count => F_Count); Assert (Condition => F_Count = 0, Message => "Unable to detach facility from logger"); end Default_Facility_Handling; ------------------------------------------------------------------------- procedure Detach_Facility_Unattached is Log : Tasked_Logger.Instance (Init => False); Facility : Facilities.Handle := new Facilities.Syslog.Instance; begin begin Facility.Set_Name ("Syslog_Facility"); Log.Detach_Facility (Name => Facility.Get_Name); Fail (Message => "could detach unattached facility"); exception when Logger.Facility_Not_Found => -- Free not attached facility, this is not done by the logger -- (since it was never attached). Alog.Logger.Free (Facility); end; declare F_Count : Natural := Natural'Last; begin -- Tasking_Error will be raised if tasked logger has terminated due -- to an unhandled exception. Log.Facility_Count (Count => F_Count); end; end Detach_Facility_Unattached; ------------------------------------------------------------------------- procedure Detach_Transform is Log : Tasked_Logger.Instance (Init => False); Transform : constant Transforms.Handle := new Transforms.Casing.Instance; Count : Natural := 0; begin Transform.Set_Name ("Casing_Transform"); Log.Attach_Transform (Transform => Transform); Log.Transform_Count (Count => Count); Assert (Condition => Count = 1, Message => "Unable to attach transform"); Log.Detach_Transform (Name => Transform.Get_Name); Log.Transform_Count (Count => Count); Assert (Condition => Count = 0, Message => "Unable to detach transform"); end Detach_Transform; ------------------------------------------------------------------------- procedure Detach_Transform_Unattached is Log : Tasked_Logger.Instance (Init => False); Transform : Transforms.Handle := new Transforms.Casing.Instance; begin begin Transform.Set_Name ("Casing_Transform"); Log.Detach_Transform (Name => Transform.Get_Name); Fail (Message => "could detach unattached transform"); exception when Logger.Transform_Not_Found => -- Free not attached Transform, this is not done by the logger -- (since it was never attached). Alog.Logger.Free (Transform); end; declare T_Count : Natural := Natural'Last; begin -- Tasking_Error will be raised if tasked logger has terminated due -- to an unhandled exception. Log.Transform_Count (Count => T_Count); end; end Detach_Transform_Unattached; ------------------------------------------------------------------------- procedure Enable_Facility_Timestamp (Facility_Handle : Facilities.Handle) is begin Facility_Handle.Toggle_Write_Timestamp (State => True); end Enable_Facility_Timestamp; ------------------------------------------------------------------------- procedure Except_Handler (Except : Ada.Exceptions.Exception_Occurrence; Caller : Ada.Task_Identification.Task_Id) is pragma Unreferenced (Except, Caller); begin Counter := Counter + 1; end Except_Handler; ------------------------------------------------------------------------- procedure Inc_Counter (F_Handle : Facilities.Handle) is pragma Unreferenced (F_Handle); begin Counter := Counter + 1; end Inc_Counter; ------------------------------------------------------------------------- procedure Initialize (T : in out Testcase) is begin T.Set_Name (Name => "Tests for tasked Logger"); T.Add_Test_Routine (Routine => Attach_Facility'Access, Name => "attach facility"); T.Add_Test_Routine (Routine => Update_Facility'Access, Name => "update a facility"); T.Add_Test_Routine (Routine => Detach_Facility_Unattached'Access, Name => "detach not attached facility"); T.Add_Test_Routine (Routine => Attach_Transform'Access, Name => "attach a transform"); T.Add_Test_Routine (Routine => Detach_Transform'Access, Name => "detach transform"); T.Add_Test_Routine (Routine => Detach_Transform_Unattached'Access, Name => "detach not attached transform"); T.Add_Test_Routine (Routine => Verify_Logger_Initialization'Access, Name => "logger initialization behavior"); T.Add_Test_Routine (Routine => Logger_Exception_Handling'Access, Name => "exception handling"); T.Add_Test_Routine (Routine => Default_Facility_Handling'Access, Name => "default facility handling"); T.Add_Test_Routine (Routine => Iterate_Facilities'Access, Name => "iterate over facilities"); T.Add_Test_Routine (Routine => Iterate_Facilities_Exceptions'Access, Name => "iterate facilities exceptions"); end Initialize; ------------------------------------------------------------------------- procedure Iterate_Facilities is Log : Tasked_Logger.Instance (Init => False); Facility1 : constant Facilities.Handle := new Facilities.File_Descriptor.Instance; Facility2 : constant Facilities.Handle := new Facilities.File_Descriptor.Instance; begin Counter := 0; Facility1.Set_Name (Name => "Facility1"); Facility2.Set_Name (Name => "Facility2"); Log.Attach_Facility (Facility => Facility1); Log.Attach_Facility (Facility => Facility2); Log.Iterate (Process => Inc_Counter'Access); Log.Clear; Assert (Condition => Counter = 2, Message => "counter not 2"); end Iterate_Facilities; ------------------------------------------------------------------------- procedure Iterate_Facilities_Exceptions is use Ada.Exceptions; Log : Tasked_Logger.Instance (Init => False); Facility1 : constant Facilities.Handle := new Facilities.File_Descriptor.Instance; begin Counter := 0; Log.Set_Except_Handler (Proc => Except_Handler'Access); Facility1.Set_Name (Name => "Facility1"); Log.Attach_Facility (Facility => Facility1); Log.Iterate (Process => Raise_Exception'Access); for I in 1 .. 30 loop exit when Counter /= 0; delay 0.1; end loop; Assert (Condition => Counter = 1, Message => "Exception counter not 1"); Log.Clear; end Iterate_Facilities_Exceptions; ------------------------------------------------------------------------- procedure Logger_Exception_Handling is Log : Tasked_Logger.Instance; Mock_Facility : constant Facilities.Handle := new Facilities.Mock.Instance; begin Counter := 0; Log.Set_Except_Handler (Proc => Except_Handler'Access); Log.Attach_Facility (Facility => Mock_Facility); Log.Log_Message (Level => Debug, Msg => "Test message"); for I in 1 .. 30 loop exit when Counter /= 0; delay 0.1; end loop; Assert (Condition => Counter = 1, Message => "Exception counter not 1"); end Logger_Exception_Handling; ------------------------------------------------------------------------- procedure Raise_Exception (F_Handle : Facilities.Handle) is begin raise Constraint_Error with "DON'T PANIC! This is a test exception!"; end Raise_Exception; ------------------------------------------------------------------------- procedure Update_Facility is Log : Tasked_Logger.Instance (Init => False); begin Counter := 0; Log.Set_Except_Handler (Proc => Except_Handler'Access); Log.Update (Name => "Nonexistent", Process => Do_Nothing'Access); for I in 1 .. 30 loop exit when Counter /= 0; delay 0.1; end loop; Assert (Condition => Counter = 1, Message => "Exception counter not 1"); declare Facility : constant Facilities.Handle := new Facilities.File_Descriptor.Instance; Facility_Name : constant String := "Test_Facility"; begin Facility.Set_Name (Name => Facility_Name); Facility.Toggle_Write_Timestamp (State => False); Assert (Condition => not Facility.Is_Write_Timestamp, Message => "Could not disable Timestamp"); Log.Attach_Facility (Facility => Facility); Log.Update (Name => Facility_Name, Process => Enable_Facility_Timestamp'Access); -- Since Update is not synchronous and we are accessing the facility -- directly we must wait for the update to actually take place. delay 0.1; Assert (Condition => Facility.Is_Write_Timestamp, Message => "Update failed"); end; end Update_Facility; ------------------------------------------------------------------------- procedure Verify_Logger_Initialization is Logger1 : Tasked_Logger.Instance; Logger2 : Tasked_Logger.Instance (Init => True); F_Count : Natural := Natural'Last; begin Logger1.Facility_Count (Count => F_Count); Assert (Condition => F_Count = 0, Message => "logger1 not empty"); Logger2.Facility_Count (Count => F_Count); Assert (Condition => F_Count = 1, Message => "logger2 empty"); end Verify_Logger_Initialization; end Tasked_Logger_Tests; libalog-0.5.0/tests/tasked_logger_tests.ads000066400000000000000000000043521241767602000210250ustar00rootroot00000000000000-- -- Copyright (c) 2008-2009, -- Reto Buerki, Adrian-Ken Rueegsegger -- -- This file is part of Alog. -- -- Alog is free software; you can redistribute it and/or modify -- it under the terms of the GNU Lesser General Public License as published -- by the Free Software Foundation; either version 2.1 of the License, or -- (at your option) any later version. -- -- Alog is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public License -- along with Alog; if not, write to the Free Software -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, -- MA 02110-1301 USA -- with Ahven.Framework; -- Tests for Alog tasked logger component. package Tasked_Logger_Tests is type Testcase is new Ahven.Framework.Test_Case with null record; procedure Initialize (T : in out Testcase); -- Initialize testcase. procedure Attach_Facility; -- Test Facility attaching to tasked logger. procedure Update_Facility; -- Test Facility update operation. procedure Detach_Facility_Unattached; -- Test Facility detaching of tasked logger with a un-attached instance. -- Verify that logger remains responsive after exception. procedure Attach_Transform; -- Test Transform attaching to tasked logger. procedure Detach_Transform; -- Test Transform detaching of tasked logger. procedure Detach_Transform_Unattached; -- Test Transform detaching of tasked logger with un-attached instance. -- Verify that logger remains responsive after exception. procedure Verify_Logger_Initialization; -- Test tasked logger instance initialization behavior. procedure Logger_Exception_Handling; -- Test tasked logger instance exception handling. procedure Default_Facility_Handling; -- Test tasked logger attaching/detaching of default facility. procedure Iterate_Facilities; -- Test tasked logger facility iteration. procedure Iterate_Facilities_Exceptions; -- Test tasked logger facility iteration with exceptions. end Tasked_Logger_Tests; libalog-0.5.0/tests/test_runner.adb000066400000000000000000000055261241767602000173240ustar00rootroot00000000000000-- -- Copyright (c) 2008-2014, -- Reto Buerki, Adrian-Ken Rueegsegger -- -- This file is part of Alog. -- -- Alog is free software; you can redistribute it and/or modify -- it under the terms of the GNU Lesser General Public License as published -- by the Free Software Foundation; either version 2.1 of the License, or -- (at your option) any later version. -- -- Alog is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public License -- along with Alog; if not, write to the Free Software -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, -- MA 02110-1301 USA -- with Ahven.Text_Runner; with Ahven.Framework; with Helper_Tests; with Log_Request_Tests; with Protected_Container_Tests; with Facility_Tests.FD; with Facility_Tests.Syslog; with Transform_Tests.Casing; with Logger_Tests; with Tasked_Logger_Tests; with Active_Logger_Tests; with Maps_Tests; with Policy_Tests; procedure Test_Runner is S : constant Ahven.Framework.Test_Suite_Access := Ahven.Framework.Create_Suite (Suite_Name => "Alog tests"); begin Ahven.Framework.Add_Test (Suite => S.all, T => new Helper_Tests.Testcase); Ahven.Framework.Add_Test (Suite => S.all, T => new Log_Request_Tests.Testcase); Ahven.Framework.Add_Test (Suite => S.all, T => new Protected_Container_Tests.Testcase); Ahven.Framework.Add_Test (Suite => S.all, T => new Maps_Tests.Testcase); Ahven.Framework.Add_Test (Suite => S.all, T => new Facility_Tests.Testcase); Ahven.Framework.Add_Test (Suite => S.all, T => new Facility_Tests.FD.Testcase); Ahven.Framework.Add_Test (Suite => S.all, T => new Facility_Tests.Syslog.Testcase); Ahven.Framework.Add_Test (Suite => S.all, T => new Transform_Tests.Testcase); Ahven.Framework.Add_Test (Suite => S.all, T => new Transform_Tests.Casing.Testcase); Ahven.Framework.Add_Test (Suite => S.all, T => new Logger_Tests.Testcase); Ahven.Framework.Add_Test (Suite => S.all, T => new Tasked_Logger_Tests.Testcase); Ahven.Framework.Add_Test (Suite => S.all, T => new Active_Logger_Tests.Testcase); Ahven.Framework.Add_Test (Suite => S.all, T => new Policy_Tests.Testcase); Ahven.Text_Runner.Run (Suite => S); Ahven.Framework.Release_Suite (T => S); end Test_Runner; libalog-0.5.0/tests/transform_tests-casing.adb000066400000000000000000000055011241767602000214440ustar00rootroot00000000000000-- -- Copyright (c) 2008, -- Reto Buerki, Adrian-Ken Rueegsegger -- -- This file is part of Alog. -- -- Alog is free software; you can redistribute it and/or modify -- it under the terms of the GNU Lesser General Public License as published -- by the Free Software Foundation; either version 2.1 of the License, or -- (at your option) any later version. -- -- Alog is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public License -- along with Alog; if not, write to the Free Software -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, -- MA 02110-1301 USA -- with Ada.Strings.Unbounded; with Alog.Transforms.Casing; package body Transform_Tests.Casing is use Alog; use Ada.Strings.Unbounded; ------------------------------------------------------------------------- procedure Initialize (T : in out Testcase) is begin T.Set_Name (Name => "Tests for Casing Transform"); T.Add_Test_Routine (Routine => Transform_Message_Lowercase'Access, Name => "transform a message to lowercase"); T.Add_Test_Routine (Routine => Transform_Message_Uppercase'Access, Name => "transform a message to uppercase"); end Initialize; ------------------------------------------------------------------------- procedure Transform_Message_Lowercase is T : Alog.Transforms.Casing.Instance; Message : constant String := "Test Message"; Transformed_Msg : Unbounded_String; Ref_Transformed_Msg : constant String := "test message"; begin T.Setup; Transformed_Msg := To_Unbounded_String ( T.Transform_Message (Info, Message)); Assert (Condition => Transformed_Msg = Ref_Transformed_Msg, Message => "Output does not match expected value (lowercase)"); T.Teardown; end Transform_Message_Lowercase; ------------------------------------------------------------------------- procedure Transform_Message_Uppercase is T : Alog.Transforms.Casing.Instance; Message : constant String := "Test Message"; Transformed_Msg : Unbounded_String; Ref_Transformed_Msg : constant String := "TEST MESSAGE"; begin T.Setup; T.Set_Mode (Alog.Transforms.Casing.Uppercase); Transformed_Msg := To_Unbounded_String ( T.Transform_Message (Info, Message)); Assert (Condition => Transformed_Msg = Ref_Transformed_Msg, Message => "Output does not match expected value (uppercase)"); T.Teardown; end Transform_Message_Uppercase; end Transform_Tests.Casing; libalog-0.5.0/tests/transform_tests-casing.ads000066400000000000000000000023351241767602000214670ustar00rootroot00000000000000-- -- Copyright (c) 2008, -- Reto Buerki, Adrian-Ken Rueegsegger -- -- This file is part of Alog. -- -- Alog is free software; you can redistribute it and/or modify -- it under the terms of the GNU Lesser General Public License as published -- by the Free Software Foundation; either version 2.1 of the License, or -- (at your option) any later version. -- -- Alog is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public License -- along with Alog; if not, write to the Free Software -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, -- MA 02110-1301 USA -- with Ahven.Framework; package Transform_Tests.Casing is type Testcase is new Ahven.Framework.Test_Case with null record; procedure Initialize (T : in out Testcase); -- Initialize testcase. procedure Transform_Message_Lowercase; -- Test lowercase message transformation. procedure Transform_Message_Uppercase; -- Test uppercase message transformation. end Transform_Tests.Casing; libalog-0.5.0/tests/transform_tests.adb000066400000000000000000000031061241767602000202010ustar00rootroot00000000000000-- -- Copyright (c) 2008, -- Reto Buerki, Adrian-Ken Rueegsegger -- -- This file is part of Alog. -- -- Alog is free software; you can redistribute it and/or modify -- it under the terms of the GNU Lesser General Public License as published -- by the Free Software Foundation; either version 2.1 of the License, or -- (at your option) any later version. -- -- Alog is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public License -- along with Alog; if not, write to the Free Software -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, -- MA 02110-1301 USA -- with Alog.Transforms.Casing; package body Transform_Tests is use Alog; ------------------------------------------------------------------------- procedure Initialize (T : in out Testcase) is begin T.Set_Name (Name => "Tests for Transforms"); T.Add_Test_Routine (Routine => Set_Name'Access, Name => "set transform name"); end Initialize; ------------------------------------------------------------------------- procedure Set_Name is T : Transforms.Casing.Instance; Expected : constant String := "Test transform"; begin T.Set_Name (Name => Expected); Assert (Condition => T.Get_Name = Expected, Message => "name not equal"); end Set_Name; end Transform_Tests; libalog-0.5.0/tests/transform_tests.ads000066400000000000000000000022441241767602000202240ustar00rootroot00000000000000-- -- Copyright (c) 2008, -- Reto Buerki, Adrian-Ken Rueegsegger -- -- This file is part of Alog. -- -- Alog is free software; you can redistribute it and/or modify -- it under the terms of the GNU Lesser General Public License as published -- by the Free Software Foundation; either version 2.1 of the License, or -- (at your option) any later version. -- -- Alog is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public License -- along with Alog; if not, write to the Free Software -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, -- MA 02110-1301 USA -- with Ahven; use Ahven; with Ahven.Framework; with Alog; -- Tests for Alog transform components. package Transform_Tests is type Testcase is new Ahven.Framework.Test_Case with null record; procedure Initialize (T : in out Testcase); -- Initialize testcase. procedure Set_Name; -- Set name of Transform test. end Transform_Tests;