Vis 2 Demo
1.0
Technical illustration type real-time rendering of geometry
Main Page
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Macros
src
utils
LogFile.cpp
Go to the documentation of this file.
1
#include <ctime>
2
#include "
LogFile.h
"
3
4
LogFile::LogFile
(
char
*file_name,
bool
overwrite)
5
{
6
// f = fopen(file_name,"wt");// mode: write text, deprecated
7
if
(overwrite)
8
{
9
fopen_s(&
f
,file_name,
"w"
);
// opens empty file for writing; if it already exists, content is destroyed
10
}
11
else
12
{
13
fopen_s(&
f
,file_name,
"a+"
);
// remove EOF and append text
14
}
15
}
16
17
LogFile::~LogFile
()
18
{
19
if
(
f
)
20
std::fclose(
f
);
21
}
22
23
void
LogFile::print
(
const
char
*text)
24
{
25
time_t rawtime;
26
struct
tm timeinfo;
27
char
time_str[81];
28
29
std::time (&rawtime);
30
localtime_s (&timeinfo, &rawtime);
31
std::strftime(time_str, 80,
"%Y-%m-%d-%H:%M:%S"
, &timeinfo);
32
33
if
(
f
)
34
{
35
std::fprintf(
f
,
"%s\t\t%s\n"
,time_str,text);
36
}
37
}
Generated on Tue Jun 11 2013 08:43:14 for Vis 2 Demo by
1.8.3.1