Skip to content

Commit 393d175

Browse files
Update README.md, prepare for 1.1.5 release
1 parent ac5d7f2 commit 393d175

File tree

6 files changed

+62
-54
lines changed

6 files changed

+62
-54
lines changed

README.md

Lines changed: 35 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ Pretty powerful logging library in about 1000 lines of code [![Build Status](htt
2323
- [Record](#record)
2424
- [Formatter](#formatter)
2525
- [TxtFormatter](#txtformatter)
26+
- [TxtFormatterUtcTime](#txtformatterutctime)
2627
- [CsvFormatter](#csvformatter)
28+
- [CsvFormatterUtcTime](#csvformatterutctime)
2729
- [FuncMessageFormatter](#funcmessageformatter)
2830
- [MessageOnlyFormatter](#messageonlyformatter)
2931
- [Converter](#converter)
@@ -45,6 +47,7 @@ Pretty powerful logging library in about 1000 lines of code [![Build Status](htt
4547
- [Wide string support](#wide-string-support)
4648
- [Performance](#performance)
4749
- [Printf style formatting](#printf-style-formatting)
50+
- [LOG_XXX macro name clashes](#log_xxx-macro-name-clashes)
4851
- [Extending](#extending)
4952
- [Custom data type](#custom-data-type)
5053
- [Custom appender](#custom-appender)
@@ -60,23 +63,28 @@ Pretty powerful logging library in about 1000 lines of code [![Build Status](htt
6063
# Introduction
6164

6265
## Hello log!
63-
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 [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).
6467

6568
Here is a minimal hello log sample:
6669

6770
```cpp
68-
#include <plog/Log.h> // Step1: include the header.
71+
#include <plog/Log.h> // Step1: include the header
6972

7073
int main()
7174
{
72-
plog::init(plog::debug, "Hello.txt"); // Step2: initialize the logger.
75+
plog::init(plog::debug, "Hello.txt"); // Step2: initialize the logger
7376

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
7679

7780
PLOGD << "Hello log!"; // short macro
7881
PLOG_DEBUG << "Hello log!"; // long macro
7982
PLOG(plog::debug) << "Hello log!"; // function-style macro
83+
84+
// Also you can use LOG_XXX macro but it may clash with other logging libraries
85+
LOGD << "Hello log!"; // short macro
86+
LOG_DEBUG << "Hello log!"; // long macro
87+
LOG(plog::debug) << "Hello log!"; // function-style macro
8088

8189
return 0;
8290
}
@@ -97,14 +105,16 @@ And its output:
97105
- No 3rd-party dependencies
98106
- Cross-platform: Windows, Linux, FreeBSD, macOS, Android, RTEMS (gcc, clang, msvc, mingw, mingw-w64, icc, c++builder)
99107
- Thread and type safe
100-
- Formatters: [TXT](#txtformatter), [CSV](#csvformatter), [FuncMessage](#funcmessageformatter)
108+
- Formatters: [TXT](#txtformatter), [CSV](#csvformatter), [FuncMessage](#funcmessageformatter), [MessageOnly](#messageonlyformatter)
101109
- Appenders: [RollingFile](#rollingfileappender), [Console](#consoleappender), [ColorConsole](#colorconsoleappender), [Android](#androidappender), [EventLog](#eventlogappender), [DebugOutput](#debugoutputappender)
102110
- [Automatic 'this' pointer capture](#automatic-this-pointer-capture) (supported only on msvc)
103111
- [Lazy stream evaluation](#lazy-stream-evaluation)
104112
- [Unicode aware](#unicode), files are stored in UTF8
105113
- Doesn't require C++11
106114
- [Extendable](#extending)
107115
- No `windows.h` dependency
116+
- Can use UTC or local time
117+
- Uses modern CMake
108118

109119
# Usage
110120
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:
114124

115125
1. Add `plog/include` to the project include paths
116126
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>`
118127

119128
## Step 2: Initialization
120129
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
623632
2014-11-11 00:29:06.261 DEBUG [4460] [Object::~Object@13]
624633
```
625634

635+
### TxtFormatterUtcTime
636+
This is a variant of [TxtFormatter](#txtformatter) that uses UTC time instead of local time.
637+
626638
### CsvFormatter
627639
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.
628640

@@ -640,6 +652,9 @@ Date;Time;Severity;TID;This;Function;Message
640652

641653
*Note: message size is limited to 32000 chars.*
642654

655+
### CsvFormatterUtcTime
656+
This is a variant of [CsvFormatter](#csvformatter) that uses UTC time instead of local time.
657+
643658
### FuncMessageFormatter
644659
This format is designed to be used with appenders that provide their own timestamps (like [AndroidAppender](#androidappender) or linux syslog facility).
645660

@@ -800,27 +815,12 @@ Stream output in plog has several improvements over the standard `std::ostream`:
800815
## Headers to include
801816
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`.
802817

803-
![Plog core and extra components](http://gravizo.com/g?@startuml;package%20"Plog%20core\\n%28no%20additional%20include,%20just%20plog/Log.h%29"%20{;%20%20class%20TxtFormatter;%20%20class%20CsvFormatter;%20%20class%20UTF8Converter;%20%20class%20RollingFileAppender;};package%20"Plog%20extra\\n%28requires%20additional%20include%29"%20{;%20%20class%20FuncMessageFormatter;%20%20class%20ConsoleAppender;%20%20class%20ColorConsoleAppender;%20%20class%20AndroidAppender;%20%20class%20DebugOutputAppender;%20%20class%20EventLogAppender;};hide%20empty%20members;hide%20empty%20fields;@enduml)
804-
<!--
805-
@startuml
806-
package "Plog core\n(no additional include, just plog/Log.h)" {
807-
class TxtFormatter
808-
class CsvFormatter
809-
class UTF8Converter
810-
class RollingFileAppender
811-
}
812-
package "Plog extra\n(requires additional include)" {
813-
class FuncMessageFormatter
814-
class ConsoleAppender
815-
class ColorConsoleAppender
816-
class AndroidAppender
817-
class DebugOutputAppender
818-
class EventLogAppender
819-
}
820-
hide empty members
821-
hide empty fields
822-
@enduml
823-
-->
818+
Core components are:
819+
- [TxtFormatter](#txtformatter)/[TxtFormatterUtcTime](#txtformatterutctime)
820+
- [CsvFormatter](#csvformatter)/[CsvFormatterUtcTime](#csvformatterutctime)
821+
- [UTF8Converter](#utf8converter)
822+
- [NativeEOLConverter](#nativeeolconverter)
823+
- [RollingFileAppender](#rollingfileappender)
824824

825825
## Unicode
826826
Plog is unicode aware and wide string friendly. All messages are converted to a system native char type:
@@ -880,6 +880,11 @@ PLOGI.printf("%d %s", 42, "test");
880880
PLOGI.printf(L"%d %S", 42, "test"); // wchar_t version
881881
```
882882

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+
883888
# Extending
884889
Plog can be easily extended to support new:
885890

@@ -977,9 +982,10 @@ There are a number of samples that demonstrate various aspects of using plog. Th
977982
|[Library](samples/Library)|Shows plog usage in static libraries.|
978983
|[MultiAppender](samples/MultiAppender)|Shows how to use multiple appenders with the same logger.|
979984
|[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).|
981986
|[ObjectiveC](samples/ObjectiveC)|Shows that plog can be used in ObjectiveC++.|
982987
|[Performance](samples/Performance)|Measures time per a log call.|
988+
|[UtcTime](samples/UtcTime)|Shows how to use UTC time instead of local time.|
983989

984990
# References
985991

samples/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ add_subdirectory(Hello)
5454
add_subdirectory(Library)
5555
add_subdirectory(MultiAppender)
5656
add_subdirectory(MultiInstance)
57-
add_subdirectory(NativeEOL)
57+
add_subdirectory(SkipNativeEOL)
5858
add_subdirectory(ObjectiveC)
5959
add_subdirectory(Performance)
6060
add_subdirectory(UtcTime)

samples/NativeEOL/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.

samples/NativeEOL/Main.cpp

Lines changed: 0 additions & 21 deletions
This file was deleted.

samples/SkipNativeEOL/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
add_executable(SkipNativeEOL Main.cpp)
2+
target_link_libraries(SkipNativeEOL plog)
3+
set_target_properties(SkipNativeEOL PROPERTIES FOLDER Samples)

samples/SkipNativeEOL/Main.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//
2+
// SkipNativeEOL - shows how to skip NativeEOLConverter.
3+
//
4+
5+
#include <plog/Log.h>
6+
#include <plog/Converters/UTF8Converter.h>
7+
8+
int main()
9+
{
10+
// NativeEOLConverter will use <CRLF> on Windows and <LF> on everything else as line endings.
11+
// It's used by default.
12+
// If you want to always use <LF> you can skip NativeEOLConverter and specify UTF8Converter directly.
13+
static plog::RollingFileAppender<plog::TxtFormatter, plog::UTF8Converter> fileAppender("SkipNativeEOL.log", 8000, 3); // Create an appender without NativeEOLConverter.
14+
plog::init(plog::debug, &fileAppender); // Initialize the logger.
15+
16+
// Write some data.
17+
for (int i = 0; i < 100; ++i)
18+
{
19+
PLOGI << "i: " << i;
20+
}
21+
22+
return 0;
23+
}

0 commit comments

Comments
 (0)