Pantheios

Pantheios

infobox software
name = Pantheios C/C++ Logging API Library


caption =
latest_release_version = 1.0.1 (beta 162)
latest_release_date = 7 October 2008
programming_language = C/C++
operating_system = MS-Windows, Unix, Mac OS X
genre = Logging
license = BSD-form license
website = http://pantheios.org/

Pantheios is an open source C/C++ logging API library, whose design focus is performance, robustness and transparency. It claims 100% type-safety, and extremely high efficiency.

Pantheios was forked from a proprietary logging architecture of Synesis Software in 2005, and is now completely free for use in both commercial and non-commercial activities, being licensed under the BSD license. It is platform-independent, working on UNIX (Linux, Solaris, FreeBSD), Mac OS X, and Windows (x86 and x64). It is compiler-independent, and is known to work with Borland, Metrowerks CodeWarrior, Comeau, Digital Mars, GCC, Intel, Sun Studio and Microsoft Visual C++ compilers.

Pantheios provides both C and C++ APIs. The C++ API is infinitely extensible to allowing logging of arbitrary types.

The API is designed to work with any logging transport (aka "back-end"), including existing logging libraries such as ACE and log4cxx.

Design Principles

The principles underpinning Pantheios are:
* the logging subsystem must always be available, including for use by other subsystems that may themselves act before (or after) main()
* the logging subsystem must be completely robust, and should never be the cause of system failure
* the logging subsystem must have extremely low cost when logging is switched off, otherwise users will make decisions about what logging information is important at compile-time, rather than at runtime

Architecture

The Pantheios architecture is divided into four functional areas:
* The Application Layer is a collection of inserter classes and function template suites that are used to define logging statements, and adapt the statement elements into a form to be passed to the core.
* The Core controls initialization of the library, and processed statement elements received from the application layer into a form to be passed to the back-end.
* The Front-end defines the process identity and determines whether each logging statement should be processed (by the core) and emitted (to the back-end).
* The Back-end emits the prepared statement via a specific output mechanism

Division of responsibilities

Use and customization of the library is divided between the library (and its authors) and users as follows:
* The application layer may be "extended", by definition of new inserter classes, or by adaptation of application types, by the user, but existing components do not usually need to be changed.
* The core never needs to be modified by the user.
* A number of "stock" front-ends and back-ends are provided in the Pantheios distribution, but for non-trivial requirements the user is expected to "replace" front-end and/or back-end(s). This supports a primary design parameter of the library: that Pantheios may be layered over existing logging libraries, such as ACE, log4cplus, log4cpp, log4cxx, simply, robustly and in a manner that preserves Pantheios' high efficiency.

Hello, World

Applying Pantheios to the classic Hello, World program gives the following examples:

;1. Single argument of literal string


#include

int main(int argc, char** argv){ pantheios::log_NOTICE("Hello world");

return EXIT_SUCCESS;}

Notable aspects are:
* inclusion of the main Pantheios C++ header, pantheios/pantheios.hpp
* use of the pantheios::log_NOTICE() application layer function, which causes the statement to be emitted at the PANTHEIOS_SEV_NOTICE (= 5, aka Syslog's LOG_NOTICE) severity level
* passing the literal C-style string "Hello world!" to pantheios::log_NOTICE()

;2. Multiple arguments; different string types


#include
#include

int main(int argc, char** argv){ const char hello [] = "hello"; std::string world("world");

pantheios::log_NOTICE(hello, " ", world);

return EXIT_SUCCESS;}

Notable aspects are:
* multiple arguments may be passed to the log statements, up to 32 in the default distribution; more can be achieved by re-running the code-generation script that accompanies the distribution
* the arguments can be of heterogeneous string types; Pantheios uses shimscite book
last = Wilson
first = Matthew
authorlink = Matthew Wilson
year = 2004
title = Imperfect C++
publisher = Addison-Wesley
id = ISBN 0-321-22877-4
] cite book
last = Wilson
first = Matthew
authorlink = Matthew Wilson
year = 2007
title = Extended STL
publisher = Addison-Wesley
id = ISBN 0-321-30550-7
] to interpret the argument types and render them as strings

;3. Logging an exception


#include
#include
#include

void say_hello(){ std::vector very_big(1000000000);

throw std::runtime_error("hello world!");}

int main(int argc, char** argv){ try { say_hello();

return EXIT_SUCCESS; } catch(std::bad_alloc&) { pantheios::logputs(PANTHEIOS_LOG_ALERT, "out of memory"); } catch(std::exception& x) { pantheios::log_ERROR("Exception: ", x); }

return EXIT_FAILURE;}

Notable aspects are:
* use of the pantheios::log_ERROR() application layer function, which causes the statement to be emitted at the PANTHEIOS_SEV_ERROR (= 3, aka Syslog's LOG_ERR) severity level
* use of pantheios::logputs() application layer function, which passes a single C-style string directly through to the logging infrastructure and is suitable for logging low-memory conditions, at the PANTHEIOS_SEV_ALERT (= 1, aka Syslog's LOG_ALERT) severity level
* passing a reference to std::exception directly to the API; Pantheios uses shims to interpret the argument types and render them as strings

Dependencies

Pantheios is dependent on several open-source libraries:
* STLSoft provides compiler and platform discrimination, along with a number of low-level, high-efficiency components
* b64 is a Base-64 encoding library, and is used by the pantheios::b64 inserter class. Is is bundled with the Pantheios distribution
* shwild is a pattern matching library, and is used by the automated testing facilities of the library. It is bundled with the Pantheios distribution
* xTests is a unit-testing library, and is used by the automated testing facilities of the library. It is bundled with the Pantheios distribution

Criticisms

Constrained by the design principles, Pantheios has attracted some criticisms, particularly in regard to its packaging and the complexity of its build: it builds many 10s of object libraries for a given target operating-system/compiler.

Other languages

Currently, the Pantheios developers are concerned primarily with C and C++. However, a COM project, Pantheios.COM, is also available from the project website. Furthermore, there are discussions about a D version, and other languages are under discussion.

References

Further reading

* [http://www.codeproject.com/KB/cpp/callback_backends.aspx "Using Callback Back-ends with the Pantheios Logging API Library"] by Matthew Wilson on [http://codeproject.com/ Code Project]
* [http://www.codeproject.com/KB/trace/PantheiosBackendIntro.aspx "An Introduction to Pantheios Back-ends, Part 1: The Back-end API"] by Matthew Wilson on [http://codeproject.com/ Code Project]
* [http://www.codeproject.com/KB/cpp/pantheios_C.aspx "Adding Logging to C Programs with the Pantheios C API"] by Matthew Wilson on [http://codeproject.com/ Code Project]

External links

* [http://pantheios.org/ Pantheios Official Website]
* [http://stlsoft.org/ STLSoft Official Website]
* [http://stlsoft-musings.blogspot.com/ STLSoft Musings] Blog
* [news://news.digitalmars.com/c++.stlsoft STLSoft newsgroup]


Wikimedia Foundation. 2010.

Игры ⚽ Поможем написать реферат

Look at other dictionaries:

  • Log4c — is a C based logging library. Its goal is to provide the C Software developer with a configurable and efficient library for logging messages. It may be linked with end user applications or other libraries that will eventually be linked into… …   Wikipedia

  • Matthew Wilson (author) — Matthew Wilson is a software engineer and author. Specializing in C/C++, he may be best known for his time as columnist and contributing editor for C/C++ Users Journal, but has also written articles for a number of other publications, as well as… …   Wikipedia

  • Log-Datei — Eine Logdatei (engl. log file) beinhaltet das automatisch erstellte Protokoll aller oder bestimmter Aktionen von Prozessen auf einem Computersystem. Die korrekte Bezeichnung dafür ist deshalb Protokoll Datei. Wichtige Anwendungen finden sich vor… …   Deutsch Wikipedia

  • Logfile — Eine Logdatei (engl. log file) beinhaltet das automatisch erstellte Protokoll aller oder bestimmter Aktionen von Prozessen auf einem Computersystem. Die korrekte Bezeichnung dafür ist deshalb Protokoll Datei. Wichtige Anwendungen finden sich vor… …   Deutsch Wikipedia

  • Logging — Eine Logdatei (engl. log file) beinhaltet das automatisch erstellte Protokoll aller oder bestimmter Aktionen von Prozessen auf einem Computersystem. Die korrekte Bezeichnung dafür ist deshalb Protokoll Datei. Wichtige Anwendungen finden sich vor… …   Deutsch Wikipedia

  • Protokoll-Datei — Eine Logdatei (engl. log file) beinhaltet das automatisch erstellte Protokoll aller oder bestimmter Aktionen von Prozessen auf einem Computersystem. Die korrekte Bezeichnung dafür ist deshalb Protokoll Datei. Wichtige Anwendungen finden sich vor… …   Deutsch Wikipedia

  • Protokolldatei — Eine Logdatei (engl. log file) beinhaltet das automatisch erstellte Protokoll aller oder bestimmter Aktionen von Prozessen auf einem Computersystem. Die korrekte Bezeichnung dafür ist deshalb Protokoll Datei. Wichtige Anwendungen finden sich vor… …   Deutsch Wikipedia

  • Server-Logfile — Eine Logdatei (engl. log file) beinhaltet das automatisch erstellte Protokoll aller oder bestimmter Aktionen von Prozessen auf einem Computersystem. Die korrekte Bezeichnung dafür ist deshalb Protokoll Datei. Wichtige Anwendungen finden sich vor… …   Deutsch Wikipedia

  • pantheon — noun Etymology: Middle English Panteon, a temple at Rome, from Latin Pantheon, from Greek pantheion temple of all the gods, from neuter of pantheios of all gods, from pan + theos god Date: 14th century 1. a temple dedicated to all the gods 2. a… …   New Collegiate Dictionary

  • Data logging — is the practice of recording sequential data, often chronologically.Etymology To log is a verb derivative of the noun logbook ; the verb form means to record in a logbook , and may have been coined in the 1820s. The term logbook itself stems from …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”