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 (35 lines) | stat: -rw-r--r-- 894 bytes parent folder | download | duplicates (2)
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
27
28
29
30
31
32
33
34
35
//
// CustomFormatter - shows how to implement a custom formatter.
//

#include <plog/Log.h>
#include <plog/Initializers/RollingFileInitializer.h>

namespace plog
{
    class MyFormatter
    {
    public:
        static util::nstring header() // This method returns a header for a new file. In our case it is empty.
        {
            return util::nstring();
        }

        static util::nstring format(const Record& record) // This method returns a string from a record.
        {
            util::nostringstream ss;
            ss << record.getMessage() << "\n"; // Produce a simple string with a log message.

            return ss.str();
        }
    };
}

int main()
{
    plog::init<plog::MyFormatter>(plog::debug, "CustomFormatter.txt"); // Initialize the logger and pass our formatter as a template parameter to init function.

    PLOGD << "A debug message!";

    return 0;
}