projects
/
dcpomatic.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix problems with FFmpeg files that have all-zero stream IDs.
[dcpomatic.git]
/
src
/
lib
/
log.cc
diff --git
a/src/lib/log.cc
b/src/lib/log.cc
index 650384bc7726986ff97800613f0ef09f2a41346f..9ddf460d43ccc1c382270e607a7634a66be09049 100644
(file)
--- a/
src/lib/log.cc
+++ b/
src/lib/log.cc
@@
-21,14
+21,17
@@
* @brief A very simple logging class.
*/
* @brief A very simple logging class.
*/
-#include <fstream>
#include <time.h>
#include <time.h>
+#include <cstdio>
#include "log.h"
#include "log.h"
+#include "cross.h"
+
+#include "i18n.h"
using namespace std;
Log::Log ()
using namespace std;
Log::Log ()
- : _level (
VERBOSE
)
+ : _level (
STANDARD
)
{
}
{
}
@@
-48,7
+51,7
@@
Log::log (string m, Level l)
string a = ctime (&t);
stringstream s;
string a = ctime (&t);
stringstream s;
- s << a.substr (0, a.length() - 1) <<
": "
<< m;
+ s << a.substr (0, a.length() - 1) <<
N_(": ")
<< m;
do_log (s.str ());
}
do_log (s.str ());
}
@@
-65,7
+68,7
@@
Log::microsecond_log (string m, Level l)
gettimeofday (&tv, 0);
stringstream s;
gettimeofday (&tv, 0);
stringstream s;
- s << tv.tv_sec <<
":" << tv.tv_usec << " "
<< m;
+ s << tv.tv_sec <<
N_(":") << tv.tv_usec << N_(" ")
<< m;
do_log (s.str ());
}
do_log (s.str ());
}
@@
-76,9
+79,22
@@
Log::set_level (Level l)
_level = l;
}
_level = l;
}
+void
+Log::set_level (string l)
+{
+ if (l == N_("verbose")) {
+ set_level (VERBOSE);
+ return;
+ } else if (l == N_("timing")) {
+ set_level (TIMING);
+ return;
+ }
+
+ set_level (STANDARD);
+}
/** @param file Filename to write log to */
/** @param file Filename to write log to */
-FileLog::FileLog (
string
file)
+FileLog::FileLog (
boost::filesystem::path
file)
: _file (file)
{
: _file (file)
{
@@
-87,7
+103,8
@@
FileLog::FileLog (string file)
void
FileLog::do_log (string m)
{
void
FileLog::do_log (string m)
{
- ofstream f (_file.c_str(), fstream::app);
- f << m << "\n";
+ FILE* f = fopen_boost (_file, "a");
+ fprintf (f, "%s\n", m.c_str ());
+ fclose (f);
}
}