File: Main.cpp

package info (click to toggle)
plog 1.1.11-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,404 kB
  • sloc: cpp: 13,637; ansic: 473; sh: 24; makefile: 4
file content (26 lines) | stat: -rw-r--r-- 930 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
//
// MessagePrefix - demonstrates usage of PLOG_MESSAGE_PREFIX
//

#define PLOG_MESSAGE_PREFIX "[MyApp] " // define PLOG_MESSAGE_PREFIX before including plog headers
#include <plog/Log.h>
#include <plog/Initializers/RollingFileInitializer.h>

int main()
{
    plog::init(plog::debug, "MessagePrefix.log");
    PLOGD << "This is a debug message with a static prefix.";
    PLOGI << "This is an info message with a static prefix.";

    // Demonstrate redefining PLOG_MESSAGE_PREFIX to a variable
    #undef PLOG_MESSAGE_PREFIX
    const char* dynamicPrefix = "[DynamicModule] ";
    static_cast<void>(dynamicPrefix); // Ensure the variable is used to avoid unused variable warning
    #define PLOG_MESSAGE_PREFIX dynamicPrefix

    PLOGW << "This is a warning message with a dynamic prefix.";

    dynamicPrefix = "[DynamicModuleUpdated] ";
    PLOGE << "This is an error message with an updated dynamic prefix.";
    return 0;
}