Pantheios
Encyclopedia
Pantheios is an open source
Open source
The term open source describes practices in production and development that promote access to the end product's source materials. Some consider open source a philosophy, others consider it a pragmatic methodology...

 C
C (programming language)
C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system....

/C++
C++
C++ is a statically typed, free-form, multi-paradigm, compiled, general-purpose programming language. It is regarded as an intermediate-level language, as it comprises a combination of both high-level and low-level language features. It was developed by Bjarne Stroustrup starting in 1979 at Bell...

 logging
Computer data logging
Computer data logging is the process of recording events, with an automated computer program, in a certain scope in order to provide an audit trail that can be used to understand the activity of the system and to diagnose problems....

 API library, whose design focus is performance, robustness and transparency. It claims 100% type-safety, and high efficiency.

Pantheios was forked from a proprietary logging
Computer data logging
Computer data logging is the process of recording events, with an automated computer program, in a certain scope in order to provide an audit trail that can be used to understand the activity of the system and to diagnose problems....

 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
Unix
Unix is a multitasking, multi-user computer operating system originally developed in 1969 by a group of AT&T employees at Bell Labs, including Ken Thompson, Dennis Ritchie, Brian Kernighan, Douglas McIlroy, and Joe Ossanna...

 (Linux
Linux
Linux is a Unix-like computer operating system assembled under the model of free and open source software development and distribution. The defining component of any Linux system is the Linux kernel, an operating system kernel first released October 5, 1991 by Linus Torvalds...

, Solaris, FreeBSD
FreeBSD
FreeBSD is a free Unix-like operating system descended from AT&T UNIX via BSD UNIX. Although for legal reasons FreeBSD cannot be called “UNIX”, as the direct descendant of BSD UNIX , FreeBSD’s internals and system APIs are UNIX-compliant...

), Mac OS X
Mac OS X
Mac OS X is a series of Unix-based operating systems and graphical user interfaces developed, marketed, and sold by Apple Inc. Since 2002, has been included with all new Macintosh computer systems...

, and Windows
Microsoft Windows
Microsoft Windows is a series of operating systems produced by Microsoft.Microsoft introduced an operating environment named Windows on November 20, 1985 as an add-on to MS-DOS in response to the growing interest in graphical user interfaces . Microsoft Windows came to dominate the world's personal...

 (x86 and x64
X86-64
x86-64 is an extension of the x86 instruction set. It supports vastly larger virtual and physical address spaces than are possible on x86, thereby allowing programmers to conveniently work with much larger data sets. x86-64 also provides 64-bit general purpose registers and numerous other...

). It is compiler-independent, and is known to work with Borland
Borland
Borland Software Corporation is a software company first headquartered in Scotts Valley, California, Cupertino, California and finally Austin, Texas. It is now a Micro Focus subsidiary. It was founded in 1983 by Niels Jensen, Ole Henriksen, Mogens Glad and Philippe Kahn.-The 1980s:...

, Metrowerks CodeWarrior
CodeWarrior
CodeWarrior is an integrated development environment for the creation of software that runs on a number of embedded systems. Prior to the acquisition of the product by Freescale Semiconductor, versions existed for Macintosh, Microsoft Windows, Linux, Solaris, PlayStation 2, Nintendo GameCube,...

, Comeau, Digital Mars
Digital Mars
Digital Mars is a small American software company owned by Walter Bright that makes C and C++ compilers for Windows and DOS. They also distribute the compilers for free on their web site....

, GCC, Intel, Sun Studio
Sun Studio (software)
The Oracle Solaris Studio compiler suite is Oracle's flagship software development product for Solaris and Linux. It was formerly known as Sun Studio...

 and Microsoft Visual C++
Visual C++
Microsoft Visual C++ is a commercial , integrated development environment product from Microsoft for the C, C++, and C++/CLI programming languages...

 compilers.

Pantheios provides both C
C (programming language)
C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system....

 and C++
C++
C++ is a statically typed, free-form, multi-paradigm, compiled, general-purpose programming language. It is regarded as an intermediate-level language, as it comprises a combination of both high-level and low-level language features. It was developed by Bjarne Stroustrup starting in 1979 at Bell...

 APIs. The C++
C++
C++ is a statically typed, free-form, multi-paradigm, compiled, general-purpose programming language. It is regarded as an intermediate-level language, as it comprises a combination of both high-level and low-level language features. It was developed by Bjarne Stroustrup starting in 1979 at Bell...

 API is infinitely extensible to allowing logging of arbitrary types.

The API is designed to work with any logging
Computer data logging
Computer data logging is the process of recording events, with an automated computer program, in a certain scope in order to provide an audit trail that can be used to understand the activity of the system and to diagnose problems....

 transport (aka "back-end"), including existing logging
Computer data logging
Computer data logging is the process of recording events, with an automated computer program, in a certain scope in order to provide an audit trail that can be used to understand the activity of the system and to diagnose problems....

 libraries such as ACE
Adaptive Communication Environment
The Adaptive Communication Environment is an open-source framework used to simplify various aspects of network programming...

 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
Hello world program
A "Hello world" program is a computer program that outputs "Hello world" on a display device. Because it is typically one of the simplest programs possible in most programming languages, it is by tradition often used to illustrate to beginners the most basic syntax of a programming language, or to...

 program gives the following examples:

1. Single argument of literal string

  1. 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
    Syslog
    Syslog is a standard for computer data logging. It allows separation of the software that generates messages from the system that stores them and the software that reports and analyzes them...

    's LOG_NOTICE) severity level

  • passing the literal C-style string "Hello world!" to pantheios::log_NOTICE

2. Multiple arguments; different string types
  1. include
  2. 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 shims to interpret the argument types and render them as strings

3. Logging an exception
  1. include
  2. include
  3. 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
    Syslog
    Syslog is a standard for computer data logging. It allows separation of the software that generates messages from the system that stores them and the software that reports and analyzes them...

    '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
    Syslog
    Syslog is a standard for computer data logging. It allows separation of the software that generates messages from the system that stores them and the software that reports and analyzes them...

    '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. It 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
Component Object Model
Component Object Model is a binary-interface standard for software componentry introduced by Microsoft in 1993. It is used to enable interprocess communication and dynamic object creation in a large range of programming languages...

 project, Pantheios.COM, is also available from the project website. Furthermore, there are discussions about a D version, and other languages are under discussion.

Further reading


External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK