-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathLogger.hpp
More file actions
38 lines (35 loc) · 732 Bytes
/
Logger.hpp
File metadata and controls
38 lines (35 loc) · 732 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
/*
* Logger.hpp
*
* Created on: 03/12/2012
* Author: polymorpher
*/
#pragma once
#include<fstream>
#include<cstdio>
#include<iostream>
#include<string>
#include<cstdarg>
namespace AliasLDA{
class Logger {
std::fstream f;
public:
bool fileLogEnabled;
bool printEnabled;
void append(std::string s, ...){
char outs[1024];
va_list argptr;
va_start(argptr, s);
vsnprintf(outs,1023,s.c_str(), argptr);
va_end(argptr);
if(printEnabled)printf("%s",outs);
if(fileLogEnabled){f<<outs;f.flush();}
}
Logger(std::string fileName,bool fileLog, bool printLog):f(fileName),
fileLogEnabled(fileLog),printEnabled(printLog){
}
Logger(){
Logger("out.log",true,true);
}
};
}