File: log.h

package info (click to toggle)
slim 1.3.4-2
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 1,928 kB
  • sloc: cpp: 3,435; ansic: 204; sh: 188; makefile: 16
file content (34 lines) | stat: -rw-r--r-- 655 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
27
28
29
30
31
32
33
34
#ifndef _LOG_H_
#define _LOG_H_

#include "const.h"
#include <fstream>

using namespace std;

static class LogUnit {
    ofstream logFile;
public:
    bool openLog(const char * filename);
    void closeLog();

    ~LogUnit() { closeLog(); }

    template<typename Type>
    LogUnit & operator<<(const Type & text) {
        logFile << text; logFile.flush();
        return *this;
    }

    LogUnit & operator<<(ostream & (*fp)(ostream&)) {
        logFile << fp; logFile.flush();
        return *this;
    }

    LogUnit & operator<<(ios_base & (*fp)(ios_base&)) {
        logFile << fp; logFile.flush();
        return *this;
    }
} logStream;

#endif