You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-[LOG_XXX macro name clashes](#log_xxx-macro-name-clashes)
48
51
-[Extending](#extending)
49
52
-[Custom data type](#custom-data-type)
50
53
-[Custom appender](#custom-appender)
@@ -60,23 +63,28 @@ Pretty powerful logging library in about 1000 lines of code [) and [automatic 'this' pointer capture](#automatic-this-pointer-capture).
66
+
Plog is a C++ logging library that is designed to be as simple, small and flexible as possible. It is created as an alternative to existing large libraries and provides some unique features as [CSV log format]((#csvformatter)) and [wide string support](#wide-string-support).
64
67
65
68
Here is a minimal hello log sample:
66
69
67
70
```cpp
68
-
#include<plog/Log.h>// Step1: include the header.
71
+
#include<plog/Log.h>// Step1: include the header
69
72
70
73
intmain()
71
74
{
72
-
plog::init(plog::debug, "Hello.txt"); // Step2: initialize the logger.
75
+
plog::init(plog::debug, "Hello.txt"); // Step2: initialize the logger
73
76
74
-
// Step3: write log messages using a special macro.
75
-
// There are several log macros, use the macro you liked the most.
77
+
// Step3: write log messages using a special macro
78
+
// There are several log macros, use the macro you liked the most
-[Unicode aware](#unicode), files are stored in UTF8
105
113
- Doesn't require C++11
106
114
-[Extendable](#extending)
107
115
- No `windows.h` dependency
116
+
- Can use UTC or local time
117
+
- Uses modern CMake
108
118
109
119
# Usage
110
120
To start using plog you need to make 3 simple steps.
@@ -114,7 +124,6 @@ At first your project needs to know about plog. For that you have to:
114
124
115
125
1. Add `plog/include` to the project include paths
116
126
2. Add `#include <plog/Log.h>` into your cpp/h files (if you have precompiled headers it is a good place to add this include there)
117
-
3. If the project include paths include `<syslog.h>` or `<sys/syslog.h>` or any other header that defines macros with names starting with "LOG", add `#define PLOG_OMIT_LOG_DEFINES`**before**`#include <plog/Log.h>`
118
127
119
128
## Step 2: Initialization
120
129
The next step is to initialize the [Logger](#logger). This is done by the following `plog::init` function:
@@ -623,6 +632,9 @@ This is a classic log format available in almost any log library. It is good for
This is a variant of [TxtFormatter](#txtformatter) that uses UTC time instead of local time.
637
+
626
638
### CsvFormatter
627
639
This is the most powerful log format. It can be easily read without any tools (but slighlty harder than [TXT format](#txtformatter)) and can be heavily analyzed if it is opened with a CSV-aware tool (like Excel). One rows can be highlighted according to their cell values, another rows can be hidden, columns can be manipulated and you can even run SQL queries on log data! This is a recommended format if logs are big and require heavy analysis. Also 'this' pointer is shown so object instances can be told apart.
This is a variant of [CsvFormatter](#csvformatter) that uses UTC time instead of local time.
657
+
643
658
### FuncMessageFormatter
644
659
This format is designed to be used with appenders that provide their own timestamps (like [AndroidAppender](#androidappender) or linux syslog facility).
645
660
@@ -800,27 +815,12 @@ Stream output in plog has several improvements over the standard `std::ostream`:
800
815
## Headers to include
801
816
The core plog functionality is provided by inclusion of `plog/Log.h` file. Extra components require inclusion of corresponding extra headers after `plog/Log.h`.
802
817
803
-

804
-
<!--
805
-
@startuml
806
-
package "Plog core\n(no additional include, just plog/Log.h)" {
PLOGI.printf(L"%d %S", 42, "test"); // wchar_t version
881
881
```
882
882
883
+
## LOG_XXX macro name clashes
884
+
`LOG_XXX` macro names may be in conflict with other libraries (for example [syslog](https://linux.die.net/man/3/syslog)). In such cases you can disable `LOG_XXX` macro by defining `PLOG_OMIT_LOG_DEFINES` and use `PLOG_XXX`.
885
+
886
+
*Define `PLOG_OMIT_LOG_DEFINES` before `#include <plog/Log.h>` or in the project settings!*
887
+
883
888
# Extending
884
889
Plog can be easily extended to support new:
885
890
@@ -977,9 +982,10 @@ There are a number of samples that demonstrate various aspects of using plog. Th
977
982
|[Library](samples/Library)|Shows plog usage in static libraries.|
978
983
|[MultiAppender](samples/MultiAppender)|Shows how to use multiple appenders with the same logger.|
979
984
|[MultiInstance](samples/MultiInstance)|Shows how to use multiple logger instances, each instance has its own independent configuration.|
980
-
|[NativeEOL](samples/NativeEOL)|Shows how to use[NativeEOLConverter](#nativeeolconverter).|
985
+
|[SkipNativeEOL](samples/SkipNativeEOL)|Shows how to skip[NativeEOLConverter](#nativeeolconverter).|
981
986
|[ObjectiveC](samples/ObjectiveC)|Shows that plog can be used in ObjectiveC++.|
982
987
|[Performance](samples/Performance)|Measures time per a log call.|
988
+
|[UtcTime](samples/UtcTime)|Shows how to use UTC time instead of local time.|
0 commit comments