Pantheios 1.0.1 beta 215 introduces the showPlus format flag, which causes leading pluses to be applied to integers (just as leading minuses will appear for negative numbers).
It is used as follows:
#include <pantheios/pan.hpp>
#include <pantheios/inserters/i.hpp>
int main()
{
pan::log_INFORMATIONAL("log -10:");
pan::log_INFORMATIONAL("without showPlus: '", pan::i(-10), "'");
pan::log_INFORMATIONAL("with showPlus: '", pan::i(-10, 0, pan::fmt::showPlus), "'");
pan::log_INFORMATIONAL("----------\n");
pan::log_INFORMATIONAL("log +10:");
pan::log_INFORMATIONAL("without showPlus: '", pan::i(+10), "'");
pan::log_INFORMATIONAL("with showPlus: '", pan::i(+10, 0, pan::fmt::showPlus), "'");
pan::log_INFORMATIONAL("----------\n");
pan::log_INFORMATIONAL("log -10 into 10-width:");
pan::log_INFORMATIONAL("without showPlus: '", pan::i(-10, 10, 0), "'");
pan::log_INFORMATIONAL("with showPlus: '", pan::i(-10, 10, pan::fmt::showPlus), "'");
pan::log_INFORMATIONAL("----------\n");
pan::log_INFORMATIONAL("log +10 into 10-width:");
pan::log_INFORMATIONAL("without showPlus: '", pan::i(+10, 10, 0), "'");
pan::log_INFORMATIONAL("with showPlus: '", pan::i(+10, 10, pan::fmt::showPlus), "'");
pan::log_INFORMATIONAL("----------\n");
pan::log_INFORMATIONAL("log -10 into 10-width left-justified:");
pan::log_INFORMATIONAL("without showPlus: '", pan::i(-10, -10, 0), "'");
pan::log_INFORMATIONAL("with showPlus: '", pan::i(-10, -10, pan::fmt::showPlus), "'");
pan::log_INFORMATIONAL("----------\n");
pan::log_INFORMATIONAL("log +10 into 10-width left-justified:");
pan::log_INFORMATIONAL("without showPlus: '", pan::i(+10, -10, 0), "'");
pan::log_INFORMATIONAL("with showPlus: '", pan::i(+10, -10, pan::fmt::showPlus), "'");
pan::log_INFORMATIONAL("----------\n");
return 0;
}
PANTHEIOS_EXTERN_C PAN_CHAR_T const PANTHEIOS_FE_PROCESS_IDENTITY[] = PANTHEIOS_LITERAL_STRING("test.scratch.showPlus.integer");
which gives the output:
[test.scratch.showPlus.integer...]: log -10:
[test.scratch.showPlus.integer...]: without showPlus: '-10'
[test.scratch.showPlus.integer...]: with showPlus: '-10'
[test.scratch.showPlus.integer...]: ----------
[test.scratch.showPlus.integer...]: log +10:
[test.scratch.showPlus.integer...]: without showPlus: '10'
[test.scratch.showPlus.integer...]: with showPlus: '+10'
[test.scratch.showPlus.integer...]: ----------
[test.scratch.showPlus.integer...]: log -10 into 10-width:
[test.scratch.showPlus.integer...]: without showPlus: ' -10'
[test.scratch.showPlus.integer...]: with showPlus: ' -10'
[test.scratch.showPlus.integer...]: ----------
[test.scratch.showPlus.integer...]: log +10 into 10-width:
[test.scratch.showPlus.integer...]: without showPlus: ' 10'
[test.scratch.showPlus.integer...]: with showPlus: ' +10'
[test.scratch.showPlus.integer...]: ----------
[test.scratch.showPlus.integer...]: log -10 into 10-width left-justified:
[test.scratch.showPlus.integer...]: without showPlus: '-10 '
[test.scratch.showPlus.integer...]: with showPlus: '-10 '
[test.scratch.showPlus.integer...]: ----------
[test.scratch.showPlus.integer...]: log +10 into 10-width left-justified:
[test.scratch.showPlus.integer...]: without showPlus: '10 '
[test.scratch.showPlus.integer...]: with showPlus: '+10 '
[test.scratch.showPlus.integer...]: ----------
The diary of the world's fastest, most flexible, and most robust C++ logging API library.
Sunday, September 27, 2015
GitHub access
Pantheios GitHub access now at:
Fork away!
- Pantheios - main C/C++ library;
- Pantheios.Extras.DiagUtil - a suite of functions that aid diagnostics;
- Pantheios.Extras.Main - which provides a suite of functions that simplify the implementation of
main()
; and - Pantheios.Extras.xHelpers - a suite of free-function templates that simplify the implementation of non-throwing APIs.
Fork away!
Pantheios 1.0.1 beta 215 released
Pantheios is an open source C/C++ Logging API library, offering an optimal
combination of 100% type-safety, efficiency, genericity and extensibility.
It is simple to use and extend, highly-portable (platform and
compiler-independent) and, best of all, it upholds the C tradition of you
only pay for what you use.
Pantheios supports logging of message statements of arbitrary complexity,
consisting of heterogeneous types.
Pantheios supports filtering of log messages based on severity level
including (but not limited to) the eight levels defined by the SysLog
protocol.
Pantheios supports back-end output, individually and in combination, to
stderr/stdout, SysLog (including a custom implementation of the SysLog
protocol for Windows), Windows debugger, Windows event log, COM Error
Object, Speech, or any custom back-end extension you care to write.
Importantly, Pantheios is readily extended to use the existing transport
mechanisms of feature-rich logging libraries such as ACE, log4cpp,
log4cplus, log4cxx.
Pantheios does not contain any compiler-specific or platform-specific
constructs. It supports UNIX (including Linux and Mac OS-X), and Windows,
and should work with any operating system. It is known to be compatible with
Borland (5.6+), Clang, Comeau (4.3.3+), Digital Mars (8.45+), GCC (3.4+), Intel
(7+), Metrowerks (8+), Microsoft Visual C++ (6.0+), and should work with any
reasonably modern C++ compiler.
Pantheios is completely free and includes source released under a BSD-style
license. Commercial servics, including bespoke customisations, are available
from Synesis Software Pty Ltd; http://synesis.com.au/contact.html
Pantheios Training is provided by Synesis Software Pty Ltd; details at
http://synesis.com.au/training.html
Release 1.0.1 beta 215 incorporates:
* added interval inserter
* added stream_character inserter
* Clang-compatibility
* VC++ 11-compatibility
* VC++ 12-compatibility
* VC++ 14-compatibility
* showPlus format flag support in pantheios::integer (pan::i)
* makefiles customisable to specify non-bundled locations of b64, shwild,
xContract, xCover, and xTests libraries (useful to getting head from GitHub)
* NOTE: Now requires STLSoft 1.9.121
Download from:
https://sourceforge.net/projects/pantheios/files/Pantheios%20%28C%20and%20Cxx%29/
Discuss at: https://sourceforge.net/projects/pantheios/forums/forum/475313
Pantheios website: http://pantheios.org/
Note: this release of Pantheios requires STLSoft 1.9.121, or later; download
from http://stlsoft.org/
combination of 100% type-safety, efficiency, genericity and extensibility.
It is simple to use and extend, highly-portable (platform and
compiler-independent) and, best of all, it upholds the C tradition of you
only pay for what you use.
Pantheios supports logging of message statements of arbitrary complexity,
consisting of heterogeneous types.
Pantheios supports filtering of log messages based on severity level
including (but not limited to) the eight levels defined by the SysLog
protocol.
Pantheios supports back-end output, individually and in combination, to
stderr/stdout, SysLog (including a custom implementation of the SysLog
protocol for Windows), Windows debugger, Windows event log, COM Error
Object, Speech, or any custom back-end extension you care to write.
Importantly, Pantheios is readily extended to use the existing transport
mechanisms of feature-rich logging libraries such as ACE, log4cpp,
log4cplus, log4cxx.
Pantheios does not contain any compiler-specific or platform-specific
constructs. It supports UNIX (including Linux and Mac OS-X), and Windows,
and should work with any operating system. It is known to be compatible with
Borland (5.6+), Clang, Comeau (4.3.3+), Digital Mars (8.45+), GCC (3.4+), Intel
(7+), Metrowerks (8+), Microsoft Visual C++ (6.0+), and should work with any
reasonably modern C++ compiler.
Pantheios is completely free and includes source released under a BSD-style
license. Commercial servics, including bespoke customisations, are available
from Synesis Software Pty Ltd; http://synesis.com.au/contact.html
Pantheios Training is provided by Synesis Software Pty Ltd; details at
http://synesis.com.au/training.html
Release 1.0.1 beta 215 incorporates:
* added interval inserter
* added stream_character inserter
* Clang-compatibility
* VC++ 11-compatibility
* VC++ 12-compatibility
* VC++ 14-compatibility
* showPlus format flag support in pantheios::integer (pan::i)
* makefiles customisable to specify non-bundled locations of b64, shwild,
xContract, xCover, and xTests libraries (useful to getting head from GitHub)
* NOTE: Now requires STLSoft 1.9.121
Download from:
https://sourceforge.net/projects/pantheios/files/Pantheios%20%28C%20and%20Cxx%29/
Discuss at: https://sourceforge.net/projects/pantheios/forums/forum/475313
Pantheios website: http://pantheios.org/
Note: this release of Pantheios requires STLSoft 1.9.121, or later; download
from http://stlsoft.org/
Labels:
Clang,
format flags,
pantheios::integer,
showPlus,
STLSoft,
VC++,
Visual C++
Monday, May 21, 2012
Extended Radio Silence - ending in Q3 2012
To anyone who's still following any of my public works - FastFormat,
Pantheios, STLSoft, Breaking Up The Monolith, Quality Matters, VOLE,
etc. - and wondering whether these activities are permanently moribund, I
want to let you know that I'll soon be free of a very intense and
overwhelmingly consuming commercial engagement over the last 2.5 years,
and the second half of this year should see much activity in
open-source, commercial, and writing activities.
Cheers
Matt
Cheers
Matt
Monday, January 10, 2011
Pantheios 1.0.1 beta 210 released: closing a vulnerability to badly written third-party libraries
The latest release of Pantheios - version 1.0.1 beta 210 - closes a vulnerability to implicit conversion of instances of fundamental types in the presence of badly-written third-party C++ libraries.
For reasons of robustness, Pantheios log statements do not accept instances of fundamental types - integers, floating-points, bool, char, and so on. Instead, users are advised to select from the set of stock inserter classes and functions provided with the library, or to define their own.
Consequently, and by design, statements such as the following will result in compilation errors:
Instead, inserters should be used:
This can be expressed more succinctly by using namespace and inserter aliases:
In a wide-string build in the presence of MFC, then rather than causing a compilation error, the 10 will actually be converted to an instance of CString, via the conversion constructor taking a TCHAR argument!
Obviously this is not desirable, particularly not for a diagnotic logging library! As of 1.0.1 beta 210, there are compile-time constraints in the application layer function templates - log(), log_DEBUG(), etc. - that cause a compile error if any argument is of fundamental type.
For reasons of robustness, Pantheios log statements do not accept instances of fundamental types - integers, floating-points, bool, char, and so on. Instead, users are advised to select from the set of stock inserter classes and functions provided with the library, or to define their own.
Consequently, and by design, statements such as the following will result in compilation errors:
#include <pantheios/pantheios.hpp>
pantheios::log_NOTICE("int: ", 10);
pantheios::log_INFORMATIONAL("float: ", 1.23);
pantheios::log_INFORMATIONAL("bool: ", true);
pantheios::log_NOTICE("int: ", 10);
pantheios::log_INFORMATIONAL("float: ", 1.23);
pantheios::log_INFORMATIONAL("bool: ", true);
Instead, inserters should be used:
#include <pantheios/pantheios.hpp>
#include <pantheios/inserters/integer.hpp>
#include <pantheios/inserters/real.hpp>
#include <pantheios/inserters/boolean.hpp>
#include <pantheios/inserters/integer.hpp>
#include <pantheios/inserters/real.hpp>
#include <pantheios/inserters/boolean.hpp>
pantheios::log_NOTICE("int: ", pantheios::integer(10));
pantheios::log_INFORMATIONAL("float: ", pantheios::real(1.23));
pantheios::log_INFORMATIONAL("bool: ", pantheios::boolean(true));
pantheios::log_INFORMATIONAL("float: ", pantheios::real(1.23));
pantheios::log_INFORMATIONAL("bool: ", pantheios::boolean(true));
This can be expressed more succinctly by using namespace and inserter aliases:
#include <pantheios/pan.hpp>
#include <pantheios/inserters/i.hpp>
#include <pantheios/inserters/real.hpp>
#include <pantheios/inserters/b.hpp>
#include <pantheios/inserters/i.hpp>
#include <pantheios/inserters/real.hpp>
#include <pantheios/inserters/b.hpp>
pan::log_NOTICE("int: ", pan::i(10));
pan::log_INFORMATIONAL("float: ", pan::real(1.23));
pan::log_INFORMATIONAL("bool: ", pan::b(true));
pan::log_INFORMATIONAL("float: ", pan::real(1.23));
pan::log_INFORMATIONAL("bool: ", pan::b(true));
Unfortunately, in the presence of ATL or MFC - or any other library that has conversion constructors and for which string access shims are defined - the former statements will compile and execute, but will not produce the expected output. Consider the following code:
#include <afx.h>
#include <pantheios/pan.hpp>
pan::log_NOTICE("int: ", 10);
#include <pantheios/pan.hpp>
pan::log_NOTICE("int: ", 10);
In a wide-string build in the presence of MFC, then rather than causing a compilation error, the 10 will actually be converted to an instance of CString, via the conversion constructor taking a TCHAR argument!
Obviously this is not desirable, particularly not for a diagnotic logging library! As of 1.0.1 beta 210, there are compile-time constraints in the application layer function templates - log(), log_DEBUG(), etc. - that cause a compile error if any argument is of fundamental type.
Labels:
ATL,
conversion constructor,
CString,
explicit,
MFC,
Pantheios,
robustness,
widestring
Friday, January 7, 2011
Pantheios::Extras::DiagUtil 0.1.1 (alpha 1)
I've just released the first publicly available version - 0.1.1 (alpha 1) - of Pantheios.Extras.DiagUtil; details here.
It allows a user to replace code such as:
with:
or, if your program is written in C, with:
The immediate advantate is clear: substantially improved transparency in your application code. There are three secondary advantages:
More memory-tracing functionality will appear in forthcoming releases.
It allows a user to replace code such as:
#if defined(_MSC_VER) && \ defined(_DEBUG) # include <crtdbg.h> #endif int main(int argc, char** argv) { #if defined(_MSC_VER) && \ defined(_DEBUG) _CrtMemState memState; _CrtMemCheckpoint(&memState); #endif int result; . . . // main program logic (which must assign to result) #if defined(_MSC_VER) && \ defined(_DEBUG) _CrtMemDumpAllObjectsSince(&memState); #endif return result; }
with:
#include <pantheios/extras/diagutil.hpp> int program(int argc, char** argv) { . . . // main program logic return EXIT_SUCCESS; } int main(int argc, char** argv) { return pantheios::extras::diagutil:: main_leak_trace::invoke(argc, argv, program); }
or, if your program is written in C, with:
#include <pantheios/extras/diagutil.h> int program(int argc, char** argv) { . . . // main program logic return EXIT_SUCCESS; } int main(int argc, char** argv) { return pantheios_extras_diagutil_main_leak_trace_invoke( argc, argv, program); }
The immediate advantate is clear: substantially improved transparency in your application code. There are three secondary advantages:
- you do not need to explicitly conditionally include crtdbg.h
- the library can be enhanced in the future to work with other compiler-extensions, without requiring any changes to your code
- you do not have to avoid the use of
return
statements in your main program logic, and to remember to assign toresult
More memory-tracing functionality will appear in forthcoming releases.
Labels:
extras,
main,
memory,
memory leaks,
Pantheios,
Pantheios Extras,
Pantheios.Extras.DiagUtil
Thursday, January 6, 2011
Pantheios::Extras::Main 0.1.1 (alpha 1) released
I've just released the first publicly available version - 0.1.1 (alpha 1) - of Pantheios.Extras.Main; details here.
It allows a user to replace code such as:
with:
As discussed in the sixth instalment of Quality Matters, Exceptions for Practically-Unrecoverable Conditions, without an exhaustive top-level try-catch statement, program robustness cannot be averred. Pantheios.Extras.Main let's you achieve that in a single statement.
It allows a user to replace code such as:
char const PROGRAM_NAME[] = "myprogram"; int main(int argc, char** argv) { try { . . . // program logic return EXIT_SUCCESS; } catch(std::bad_alloc&) { pantheios::logputs(pantheios::alert, "out of memory"); fprintf(stderr, "%s: out of memory\n", PROGRAM_NAME); } catch(std::exception& x) { pantheios::log_CRITICAL(x); fprintf(stderr, "%s: %s\n", PROGRAM_NAME, x.what()); } catch(...) { pantheios::logputs(pantheios::emergency, "unexpected unknown failure"); fprintf(stderr, "%s: unexpected unknown failure\n", PROGRAM_NAME); } return EXIT_FAILURE; }
with:
char const PROGRAM_NAME[] = "myprogram"; int program(int argc, char** argv) { . . . // program logic return EXIT_SUCCESS; } int main(int argc, char** argv) { return pantheios::extras::main::invoke(argc, argv, program, PROGRAM_NAME); }
As discussed in the sixth instalment of Quality Matters, Exceptions for Practically-Unrecoverable Conditions, without an exhaustive top-level try-catch statement, program robustness cannot be averred. Pantheios.Extras.Main let's you achieve that in a single statement.
Labels:
contingent action,
extras,
logputs,
main,
Pantheios Extras,
Pantheios.Extras.Main,
try-catch
Subscribe to:
Posts (Atom)