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 (33 lines) | stat: -rw-r--r-- 827 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
//
// CustomType - shows how to print a custom type to the log stream.
//

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

struct Point // This is our custom type that we want to print to the log stream.
{
    int x;
    int y;
};

namespace plog
{
    Record& operator<<(Record& record, const Point& pt) // Implement a stream operator for our type.
    {
        return record << "(" << pt.x << ";" << pt.y << ")";
    }
}

int main()
{
    plog::init(plog::debug, "CustomType.txt"); // Initialize the logger.

    Point pt1 = { 0, 0 };
    Point pt2 = { 10, -5 };

    PLOGI << "We've got a line with coords: " << pt1 << pt2; // Print our type to the log stream.
    PLOGI << pt1 << pt2 << " - test for a custom type at begin of the stream"; // Print our type to the log stream.

    return 0;
}