-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlogprinter.h
More file actions
39 lines (33 loc) · 716 Bytes
/
logprinter.h
File metadata and controls
39 lines (33 loc) · 716 Bytes
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
36
37
38
#ifndef _LOG_PRINTER_H_
#define _LOG_PRINTER_H_
#include <ostream>
#include <string>
#ifdef ENCLAVED
#include <libc_mock/libc_proxy.h>
extern "C" { int printf(const char*,...); }
namespace std {
const std::string endl = "\n";
template <class charT>
class basic_ostream {
public:
basic_ostream& operator<<(const std::string &s) {
printf("%s",s.c_str());
}
};
}
#endif
class LogPrinter {
public:
LogPrinter(std::basic_ostream<char> &stream) : stream_(stream) {}
void println(const std::string &line) {
stream_ << line
#ifdef ENCLAVED
+ std::endl; // this avoids two ocalls
#else
<< std::endl;
#endif
}
private:
std::basic_ostream<char> &stream_;
};
#endif