mirror of
https://github.com/KjellKod/g3log.git
synced 2025-02-25 07:41:09 +01:00
Updated README... still in progress
This commit is contained in:
parent
8f7db77177
commit
f61af5529c
144
README
144
README
@ -1,12 +1,17 @@
|
|||||||
EXAMPLE USAGE OF G2LOG
|
# G3Log (text below is in progress)
|
||||||
=======================
|
|
||||||
Optional to use either streaming or printf-like syntax
|
## EXAMPLE USAGE
|
||||||
LOG(INFO) << "As Easy as ABC or " << 123;
|
#### Optional to use either streaming or printf-like syntax
|
||||||
or
|
```
|
||||||
LOGF(WARNING, "Printf-style syntax is also %s", "available");
|
LOG(INFO) << "streaming API is as easy as ABC or " << 123;
|
||||||
|
|
||||||
|
LOGF(WARNING, "Printf-style syntax is also %s", "available");
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
Conditional logging
|
|
||||||
|
|
||||||
|
#### Conditional logging
|
||||||
int less = 1; int more = 2
|
int less = 1; int more = 2
|
||||||
LOG_IF(INFO, (less<more)) <<"If [true], then this text will be logged";
|
LOG_IF(INFO, (less<more)) <<"If [true], then this text will be logged";
|
||||||
|
|
||||||
@ -14,97 +19,65 @@ Conditional logging
|
|||||||
LOGF_IF(INFO, (less<more), "if %d<%d then this text will be logged", less,more);
|
LOGF_IF(INFO, (less<more), "if %d<%d then this text will be logged", less,more);
|
||||||
|
|
||||||
|
|
||||||
Design-by-Contract
|
|
||||||
CHECK(false) will trigger a "fatal" message. It will be logged, and then the
|
|
||||||
|
#### Design-by-Contract
|
||||||
|
*CHECK(false)* will trigger a "fatal" message. It will be logged, and then the
|
||||||
application will exit.
|
application will exit.
|
||||||
|
|
||||||
CHECK(less != more); // not FATAL
|
```
|
||||||
CHECK(less > more) << "CHECK(false) triggers a FATAL message");
|
CHECK(less != more); // not FATAL
|
||||||
|
CHECK(less > more) << "CHECK(false) triggers a FATAL message");
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## What G3Log is:
|
||||||
|
* ***G3log*** is the acting name for the third version of g2log and it stands for ***g2log with dynamic sinks***
|
||||||
|
* G3log is an asynchronous, "crash-safe" logger. You can read more about it's use here [[g2log version]](
|
||||||
|
http://www.codeproject.com/Articles/288827/g2log-An-efficient-asynchronous-logger-using-Cplus)
|
||||||
|
|
||||||
|
|
||||||
WHAT IS G2LOG?
|
## Benefits you get when using G3log ##
|
||||||
====================
|
1. Easy to use, clean syntax and blazingly fast logger.
|
||||||
In depth information can be found at
|
|
||||||
http://www.codeproject.com/Articles/288827/g2log-An-efficient-asynchronous-logger-using-Cplus
|
|
||||||
|
|
||||||
|
2. All the slow log I/O disk access is done in a background thread. This ensures that the
|
||||||
|
|
||||||
Or just read the short summary below:
|
|
||||||
-------------------------------------
|
|
||||||
|
|
||||||
G2log is an asynchronous, "crash safe" logger and design-by-contract library.
|
|
||||||
What this means in practice is that
|
|
||||||
|
|
||||||
1. All the slow I/O disk access is done in a background thread. This ensures that the
|
|
||||||
other parts of the software can immediately continue with their work after making a
|
other parts of the software can immediately continue with their work after making a
|
||||||
log entry.
|
log entry.
|
||||||
|
|
||||||
2. g2log provides logging, Design-by-Contract [#CHECK], and flush of log to file at
|
3. G3log provides logging, Design-by-Contract [#CHECK], and flush of log to file at
|
||||||
shutdown. Buffered logs will be written to file before the application shuts down.
|
shutdown. Buffered logs will be written to the sink before the application shuts down.
|
||||||
|
|
||||||
3. It is thread safe, so using it from multiple threads is completely fine.
|
4. It is thread safe, so using it from multiple threads is completely fine.
|
||||||
|
|
||||||
4. It is CRAsH SAFE, in that it will catch certain fatal signals, so if your application crashes due to, say a segmentation fault, SIGSEGV, or some other fatal
|
5. It is *CRASH SAFE*. It will save the made logs to the sink before it shuts down.
|
||||||
signals it will log and save to file this crash and all previously buffered log
|
The logger will catch certain fatal signals, so if your application crashes due to, say a segmentation fault, *SIGSEGV*, or some other fatal signal it will log and save the crash and all previously buffered log
|
||||||
entries before exiting.
|
entries before exiting.
|
||||||
|
|
||||||
|
|
||||||
5. It is cross platform. For now, tested on Windows7 and Ubuntu
|
6. It is cross platform. Tested and used by me or by clients on OSX, Windows, Ubuntu, CentOS
|
||||||
|
|
||||||
6. On Ubuntu a caught fatal signal will generate a stack dump to the log. This is
|
7. On *Nix* systems a caught fatal signal will generate a stack dump to the log. A Beta version exist on Windows and can be released on request.
|
||||||
not yet available on Windows due to the platforms complexity when traversing the
|
|
||||||
stack. Stack dump on Windows will be released later and a beta is available on
|
|
||||||
request.
|
|
||||||
|
|
||||||
7. G2log is used in commercial products as well as hobby projects since early 2011.
|
|
||||||
|
8. G2log is used world wide in commercial products as well as hobby projects since early 2011.
|
||||||
The code is given for free as public domain. This gives the option to change, use,
|
The code is given for free as public domain. This gives the option to change, use,
|
||||||
and do whatever with it, no strings attached.
|
and do whatever with it, no strings attached.
|
||||||
|
|
||||||
8. The stable version of g2log is available at https://bitbucket.org/KjellKod/g2log
|
9. Three versions of g2log exist.
|
||||||
The in-development g2log where new features are tried out is available at
|
* This version: g3log : which is made to faciliate easy adding of custom log receivers.
|
||||||
https://bitbucket.org/KjellKod/g2log-dev ongoing and released features can be
|
* [g2log-dev](https://bitbucket.org/KjellKod/g2log-dev): Acting as feature try-out and playground.
|
||||||
seen at https://bitbucket.org/KjellKod/g2log-dev/wiki/Home
|
* [g2log](https://bitbucket.org/KjellKod/g2log): The original. Simple, easy to modify and with the most OS support. Clients use g2log on environments such as OSX/Clang, Ubuntu, CentOS, Windows/mingw, Windows/Visual Studio.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
LATEST CHANGES
|
# TO WRITE
|
||||||
=====================
|
* Example of how to use G2log
|
||||||
2012, Oct 14th
|
* Sinks easy to follow examples
|
||||||
* Complete threadsafe use of localtime for timestamp. (see code: g2time)
|
|
||||||
* Runtime change of filename, request of filename. (see code g2logwoker g2future)
|
|
||||||
* Tested on
|
|
||||||
x86 Windows7: Visual Studio 2012 Desktop Express
|
|
||||||
x86 Ubuntu 11.04: gcc 4.7.3
|
|
||||||
x64 Ubuntu 12...: gcc 4.7.2
|
|
||||||
x64 Windows7: Visual Studio 2012 Professional
|
|
||||||
|
|
||||||
NOTE: It does NOT work with "Visual Studio 11 Beta" (not as C++11 compliant
|
|
||||||
as VS2012)
|
|
||||||
|
|
||||||
|
|
||||||
|
# BUILDING g2log:
|
||||||
HOW TO BUILD
|
|
||||||
===================
|
|
||||||
This g2log is a snapshot from KjellKod repository.
|
|
||||||
It contains what is needed to build example, unit test and performance test of g2log.
|
|
||||||
|
|
||||||
justthread C++11 thread library is no longer needed.
|
|
||||||
* On Windows it is enough to use Visual Studio 11 (2012).
|
|
||||||
* On Linux it is enough to use gcc4.7.2.
|
|
||||||
|
|
||||||
The CMakeFile.txt is updated to reflect that, the justthread parts is commented
|
|
||||||
away in case someone still needs that.
|
|
||||||
|
|
||||||
If you want to integrate g2log in your own software you need the files under
|
|
||||||
g2log/src
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
BUILDING g2log:
|
|
||||||
-----------
|
-----------
|
||||||
The default is to build an example binary 'g2log-FATAL'
|
The default is to build an example binary 'g2log-FATAL'
|
||||||
I suggest you start with that, run it and view the created log also.
|
I suggest you start with that, run it and view the created log also.
|
||||||
@ -113,14 +86,14 @@ If you are interested in the performance or unit tests then you can
|
|||||||
enable the creation of them in the g2log/CMakeLists.txt file. See that file for
|
enable the creation of them in the g2log/CMakeLists.txt file. See that file for
|
||||||
more details
|
more details
|
||||||
|
|
||||||
--- Building on Linux ---
|
*** Building on Linux ***
|
||||||
cd g2log
|
cd g2log
|
||||||
mkdir build
|
mkdir build
|
||||||
cd build
|
cd build
|
||||||
cmake ..
|
cmake ..
|
||||||
make
|
make
|
||||||
|
|
||||||
--- Building on Windows ---
|
*** Building on Windows ***
|
||||||
Please use the Visual Studio 11 (2012) command prompt "Developer command prompt"
|
Please use the Visual Studio 11 (2012) command prompt "Developer command prompt"
|
||||||
cd g2log
|
cd g2log
|
||||||
mkdir build
|
mkdir build
|
||||||
@ -131,32 +104,15 @@ Release\g2log-FATAL.exe
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
CONTENTS
|
#SOURCE CONTENTS
|
||||||
===========================
|
|
||||||
3rdParty -- gtest, glog.
|
3rdParty -- gtest, glog.
|
||||||
-----------------------
|
-----------------------
|
||||||
gtest is needed for the unit tests.
|
*gtest is needed for the unit tests.
|
||||||
glog is only needed if you want to run the glog vs g2log comparison tests
|
*glog is only needed if you want to run the glog vs g2log comparison tests
|
||||||
|
|
||||||
gtest is enabled as a DEFAULT option in the CmakeFiles.txt file. If the unit test
|
|
||||||
is not important for you then just DISABLE that option. By default the gtest zipped
|
|
||||||
library must be UNPACKED before it is used (compilation)
|
|
||||||
|
|
||||||
gtest It IS included by the CMake and you don't need to do install or compile it in
|
|
||||||
any other way than through the g2log cmake setup.
|
|
||||||
|
|
||||||
Google's glog is not included and must be installed ONLY IF you want to run the comparison tests
|
|
||||||
|
|
||||||
|
|
||||||
About the A ctive Object
|
|
||||||
--------------------
|
|
||||||
Is made with standard C++ components with the help of the latest C++11 and std::thread features (thanks to justthread). For more details see
|
|
||||||
www.kjellkod.cc/active-object-with-cpp0x.
|
|
||||||
|
|
||||||
An example is provided. Other examples on pre C++0x Active Objects can also be
|
If you like this logger (or not) it would be nice with some feedback. That way I can
|
||||||
found at www.kjellkod.cc (code page)
|
|
||||||
|
|
||||||
If you like it (or not) it would be nice with some feedback. That way I can
|
|
||||||
improve g2log and it is also nice to see if someone is using it. If you have
|
improve g2log and it is also nice to see if someone is using it. If you have
|
||||||
ANY questions or problems please do not hesitate in contacting me on my blog
|
ANY questions or problems please do not hesitate in contacting me on my blog
|
||||||
http://kjellkod.wordpress.com/2011/11/17/kjellkods-g2log-vs-googles-glog-are-asynchronous-loggers-taking-over/
|
http://kjellkod.wordpress.com/2011/11/17/kjellkods-g2log-vs-googles-glog-are-asynchronous-loggers-taking-over/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user