Introduction to Pantheios, the fastest program diagnosis logstore in the C/C ++ Field

Source: Internet
Author: User
Tags vc9

Pantheios is currently the fastest program diagnosis logstore in the C/C ++ field. It has powerful functions and outstanding performance. The following is a brief introduction.
The essence of Pantheios
1. It is the log api library used for program diagnosis, not the diagnosis logstore.
2. Open source, 100% free.
3. dependent on several third-party libraries, these libraries are also open-source and 100% free of charge, including:
A. xTests is a simple lightweight unit/component Test Library for c/c ++. This library is only used in pantheios unit tests.
B. b64 a lightweight, simple, and superior b64 encoding implementation, used in the pantheios: b64 pluger
C. shwild is a unix shell-compatible wildcard library, which is only used in unit tests of pantheios.
D. STLSOFT it is not an stl replacement library, but an stl extension library. It provides many different compatibility attributes between systems and compilers, making pantheios implementation easier.
4. It is faster than all other important log diagnostic libraries. Logstore Performance Comparison Test
5. 100% type security
6. Select the log output tool (for example, the backend) at the link time. The reason is:
The log diagnostic database must be available anywhere in the code without waiting for main to set the log output. The result is that the link settings are difficult.
7. good scalability.
8. It has been used by some important commercial software.
9. Good portability has passed mainstream c ++ compiler tests.
10. Pantheios is developed and maintained by a very active team.
Pantheios Structure
It consists of four parts:
1. Application Layer
The log expression used by the application, such as log_DEBUG () and log_INFORMATIONAL.
2. Core Layer
Efficiently (frequently, no memory needs to be applied for during processing) to connect each log element to one piece.
3. Front-end)
It allows you to process and detect whether logs of a given level need to be output. (Note: the front-end database users can implement it themselves or use the ones already implemented by Pantheios)
4. Back-end)
Output the logs prepared by the Core to the output stream (for example, console, COM error object, syslog, Windows event log ...). (Note: You can implement the backend database by yourself, or use the ones already implemented by Pantheios)
Patheios Application Layer Composition
1. Each set of log functions supports 1 to 32 parameters.
2. A total of 8 log functions are provided, including:
Log_DEBUG (), log_INFORMATIONAL (), log_NOTICE (), log_WARNING (), log_ERROR (), log_CRITICAL (), log_ALERT (), and log_EMERGENCY ().
These parameters have the same effect as those added by log.
3. Two inserts for processing values: integer and real
4. One plug-in for processing pointers: pointer
5. One plug-in for processing non-type memory blocks: blob (Note: there is also an extended class b64, which is used to represent a non-Type Base-64 memory block .)
Using these functions and plug-ins, you can write simple diagnostic log statements, such:
L output an exception log
Try
{
//...
} Catch (std: exception & x ){
Pantheios: log_ERROR ("Exception encountered:", ex );
}
L log output with Parameters
Void fun (std: string const & sq, char const * s2, struct tm const * t ){
Pantheios: log (pantheios: debug, "func (", s1, "," s2, ",", t ,")");
}
L mixed type parameter log output
Int I;
Flost f;
GUID;
Pantheios: log (pantheios: notice (99)
, "Int =", pantheios: integer (I)
, "Float =", pantheios: real (f)
, "HWND =", hwnd
, "GUID =", guid );
At the application layer, you only need the header file pantheios/pantheios. hpp. If you use the plug-in, you also need pantheios/inserters. hpp.
Core Layer
The core layer is called by the application layer. In some cases, these APIs are useful to the application layer. For example,
Int pantheios_isSeverityLogged (pan_sev_t severity)
Used to detect whether the specified log needs to be output.
In addition, by directly using core APIs, c code can also directly use pantheios. These functions are:
Pantheios_printf () and pantheios_vprintf ()
Example:
Int I;
Float f;
Pantheios_printf (PANTHEIOS_SEV_INFORMATIONAL, "int = % d, float = % g", I, f );
It is worth noting that if you use these two functions directly, pantheios cannot provide you with type-safe calls.
Front-end)
The front-end is a library that provides four functions. It provides the process ID used for log expression and detection. during runtime, it is used to detect whether logs of a specified level need to be output:
1. PANTHEIOS_CALL (int) pantheios_fe_init (int reserved, void ** ptoken );
2. PANTHEIOS_CALL (int) pantheios_fe_uninit (void * token );
3. PANTHEIOS_CALL (char const *) pantheios_fe_processIdentity (void * token );
4. PANTHEIOS_CALL (int) pantheios_fe_isSeverityLogged (void * token, int severity, int backEndId );
Pantheios_fe_init (), pantheios_fe_uninit (), and pantheios_fe_processIdentity () are called only once during database initialization.
Pantheios_fe_isSeverityLogged () is called when logs are output to check whether logs of the specified level need to be output to back_end.
Select the front-end at the software link time.
Pantheios provides a front-end implementation: fe. simple.
Fe. simple requires two simple steps:
1. link this library
For example, in vc9, You need to link the debug Library
Pantheios.1.fe. simple. vc9.mt. debug. lib
Release
Pantheios.1.fe. simple. vc9.mt. lib
If your compiler supports implicit links (implicit linking, such as vc), you only need to include the specified header file:
# Include <pantheios/implicit_link/fe. simple. h>
2. Add the following statement to your program:
PANTHEIOS_EXTERN_C const char PANTHEIOS_FE_PROCESS_IDENTITY [] = "my-process ";
This symbol is required in the function pantheios_fe_processIdentity () of fe. simple.
User-Defined front-end Implementation Guide
Implementing a custom front-end is quite simple. The minimum implementation requirement is that the pantheios_fe_processIdentity () function you implement must return a non-zero-ending string. The function pantheios_fe_isSeverityLogged () returns a non-zero value and the pantheios_fe_init () function () and pantheios_fe_uninit (). The example is as follows:
PANTHEIOS_CALL (int) pantheios_fe_init (void * reserved, void ** ptoken)
{
* Ptoken = NULL;
Return 0;
}
PANTHEIOS_CALL (void) pantheios_fe_uninit (void * token ){}
PANTHEIOS_CALL (char const *) pantheios_fe_processIdentity (void * token)
{
Return "My Process ";
}
PANTHEIOS_CALL (int) pantheios_fe_isSeverityLogged (void * token, int severity, int backEndId)
{
Return 1; // Allow all levels
}
Back-end)
The backend database provides three functions to output backend logs:
1. PANTHEIOS_CALL (int) pantheios_be_init (char const * processIdentity, int reserved, void ** ptoken );
2. PANTHEIOS_CALL (void) pantheios_be_uninit (void * token );
3. PANTHEIOS_CALL (int) pantheios_be_logEntry (void * feToken, void * beToken, int severity, char const * entry, size_t cchEntry );
Pantheios_be_init () and pantheios_be_uninit () are called only once during database initialization (Anti-initialization). When the application layer requires that logs be output and logs () return non-0, pantheios_be_logEntry () is called once.
Background library selection is implemented at the link time. Pantheios has implemented the following backend libraries:
L be. ACE-log output to the ACE log framework
L be. COMErrorObject-log output to COM error object
L be. fprintf-output logs to the console through fprintf ()
L be. null-No output
L be. syslog-use unix SysLog API functions to output logs by Syslog protocol
L be. Win32Console-outputs logs to the windows Console window. Note that the log levels are different and the colors are different.
L be. Win32Debugger-output logs to the windows debugging window
L be. Win32syslog-use windows SysLog protocol to output logs
L be. WindowsEventLog-output logs to Windows Event Log
There is also a magic backend library be. lrsplit, which uses the combination mode to output logs to the local backend and remote backend.
Instructions on using backend libraries provided by pantheios
This is too simple. You need to specify the library to be used when processing the link. You don't need to do anything else! For example, if vc9 uses the be. fprintf backend library, you need to specify links to the following libraries:
Debug
Pantheios.1.be. fprintf. vc9.mt. debug. lib and pantheios.1.bec. fprintf. vc9.mt. debug. lib
Release
Pantheios.1.be. fprintf. vc9.mt. lib and pantheios.1.bec. fprintf. vc9.mt. lib
Why use two databases? To support be. lrsplit, the backend databases implemented by pantheios are composed of four parts. The list is as follows:
 

Name
Independent interface library
Local interface library
Remote interface library
Public implementation Library
ACE
Be. ACE
Bel. ACE
Ber. ACE
Bec. ACE
COM Error Object
Be. COMErrorObject
Bel. COMErrorObject
Ber. COMErrorObject
Bec. COMErrorObject
File
Be. file
Bel. file
Ber. file
Bec. file
Fprintf
Be. fprintf
Bel. fprintf
Ber. fprintf
Bec. fprintf
Null
Be. null
Bel. null
Ber. null
Bec. null
SysLog
Be. syslog
Bel. syslog
Ber. syslog
Bec. syslog
Win32 Console
Be. Win32Console
Bel. Win32Console
Ber. Win32Console
Bec. Win32Console
Win32 Debugger
Be. Win32Debugger
Bel. Win32Debugger
Ber. Win32Debugger
Bec. Win32Debugger
Win32 SysLog
Be. Win32sysLog
Bel. Win32sysLog
Ber. Win32sysLog
Bec. Win32sysLog
Windows Event Log
Be. WindowsEventLog
Bel. WindowsEventLog
Ber. WindowsEventLog
Bec. WindowsEventLog
 


Author: lzy0168

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.