30 #include <boost/thread/mutex.hpp>
31 #include <boost/format.hpp>
36 #include <android/log.h>
40 #define DEFAULT_LOGFILE "gnash-dbg.log"
44 #define _(String) gettext (String)
45 #define N_(String) gettext_noop (String)
49 #define LOG_ONCE(x) { \
50 static bool warned = false; \
51 if (!warned) { warned = true; x; } \
54 # include <boost/preprocessor/arithmetic/inc.hpp>
55 # include <boost/preprocessor/repetition/enum_params.hpp>
56 # include <boost/preprocessor/repetition/repeat.hpp>
57 # include <boost/preprocessor/repetition/repeat_from_to.hpp>
58 # include <boost/preprocessor/seq/for_each.hpp>
63 #define __FUNCDNAME__ __FUNCTION__
73 static LogFile& getDefaultInstance();
99 void log(
const std::string& label,
const std::string& msg);
106 void log(
const std::string& msg);
126 void setLogFilename(
const std::string& fname);
174 void setWriteDisk(
bool b);
180 typedef void (*logListener)(
const std::string&
s);
192 bool openLog(
const std::string& filespec);
204 bool openLogIfNeeded();
210 boost::mutex _ioMutex;
213 std::ofstream _outstream;
235 std::string _filespec;
237 std::string _logFilename;
239 logListener _listener;
260 #define TOKENIZE_FORMAT(z, n, t) % t##n
265 #define TOKENIZE_ARGS(z, n, t) BOOST_PP_COMMA_IF(n) const T##n& t##n
270 #define LOG_TYPES (error) (debug) (unimpl) (aserror) (swferror) \
271 (security) (action) (parse) (trace) (abc) (network)
291 #define LOG_TEMPLATES(z, n, data)\
292 template<BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(n), typename T)>\
293 inline void log_##data(BOOST_PP_REPEAT(BOOST_PP_INC(n), TOKENIZE_ARGS, t)) \
295 if (LogFile::getDefaultInstance().getVerbosity() == 0) return; \
296 boost::format f(t0); \
297 using namespace boost::io; \
298 f.exceptions(all_error_bits ^ (too_many_args_bit | \
300 bad_format_string_bit)); \
301 processLog_##data(f BOOST_PP_REPEAT_FROM_TO(1, \
303 TOKENIZE_FORMAT, t));\
310 #define ARG_NUMBER 10
315 #define GENERATE_LOG_TYPES(r, _, t) \
316 BOOST_PP_REPEAT(ARG_NUMBER, LOG_TEMPLATES, t)
323 #undef TOKENIZE_FORMAT
324 #undef GENERATE_LOG_TYPES
339 #ifndef VERBOSE_PARSE
340 #define VERBOSE_PARSE 1
344 #ifndef VERBOSE_ACTION
345 #define VERBOSE_ACTION 1
349 #ifndef VERBOSE_ASCODING_ERRORS
350 #define VERBOSE_ASCODING_ERRORS 1
354 #ifndef VERBOSE_MALFORMED_SWF
355 #define VERBOSE_MALFORMED_SWF 1
359 #ifndef VERBOSE_NETWORKING
360 #define VERBOSE_NETWORKING 1
364 #define IF_VERBOSE_PARSE(x) do { if ( LogFile::getDefaultInstance().getParserDump() ) { x; } } while (0);
366 #define IF_VERBOSE_PARSE(x)
370 #define IF_VERBOSE_ACTION(x) do { if ( LogFile::getDefaultInstance().getActionDump() ) { x; } } while (0);
372 #define IF_VERBOSE_ACTION(x)
376 #define IF_VERBOSE_NETWORK(x) do { if ( LogFile::getDefaultInstance().getNetwork() ) { x; } } while (0);
378 #define IF_VERBOSE_NETWORK(x)
381 #if VERBOSE_ASCODING_ERRORS
383 #define IF_VERBOSE_ASCODING_ERRORS(x) { if ( gnash::RcInitFile::getDefaultInstance().showASCodingErrors() ) { x; } }
385 #define IF_VERBOSE_ASCODING_ERRORS(x)
388 #if VERBOSE_MALFORMED_SWF
390 #define IF_VERBOSE_MALFORMED_SWF(x) { if ( gnash::RcInitFile::getDefaultInstance().showMalformedSWFErrors() ) { x; } }
392 #define IF_VERBOSE_MALFORMED_SWF(x)
401 log_debug(
"entering");
406 log_debug(
"%s enter", func);
409 log_debug(
"No Function Name! enter");
413 log_debug(
"%s returning", _func);
419 #ifndef HAVE_FUNCTION
421 #define dummystr(x) # x
422 #define dummyestr(x) dummystr(x)
423 #define __FUNCTION__ __FILE__":"dummyestr(__LINE__)
425 #define __FUNCTION__ __func__
429 #ifndef HAVE_PRETTY_FUNCTION
430 #define __PRETTY_FUNCTION__ __FUNCTION__
433 #if defined(__cplusplus) && defined(__GNUC__)
434 #define GNASH_REPORT_FUNCTION \
435 const gnash::HostFunctionReport hfr(__PRETTY_FUNCTION__)
436 #define GNASH_REPORT_RETURN
438 #define GNASH_REPORT_FUNCTION \
439 gnash::log_debug("entering")
441 #define GNASH_REPORT_RETURN \
442 gnash::log_debug("returning")
447 #endif // GNASH_LOG_H
void setActionDump(int x)
Definition: log.h:141
void setVerbosity(int x)
Definition: log.h:133
HostFunctionReport()
Definition: log.h:400
void setParserDump(int x)
Definition: log.h:157
void processLog_action(const boost::format &fmt)
Definition: log.cpp:235
SWFStream & s
Definition: DefineBitsTag.cpp:73
bool getWriteDisk() const
Definition: log.h:176
void registerLogCallback(logListener l)
Definition: log.h:182
Definition: GnashKey.h:158
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:40
int getVerbosity() const
Definition: log.h:137
std::string hexify(const unsigned char *p, size_t length, bool ascii)
Convert a sequence of bytes to hex or ascii format.
Definition: log.cpp:51
~HostFunctionReport()
Definition: log.h:412
int getNetwork() const
Definition: log.h:153
void processLog_abc(const boost::format &fmt)
Definition: log.cpp:146
void processLog_trace(const boost::format &fmt)
Definition: log.cpp:123
#define _(String)
Definition: log.h:44
void setNetwork(int x)
Definition: log.h:145
void processLog_network(const boost::format &fmt)
Definition: log.cpp:169
void processLog_error(const boost::format &fmt)
Definition: log.cpp:180
void processLog_security(const boost::format &fmt)
Definition: log.cpp:202
void setVerbosity()
Definition: log.h:129
Definition: klash_part.cpp:329
void processLog_parse(const boost::format &fmt)
Definition: log.cpp:158
boost::int32_t x
Definition: BitmapData_as.cpp:434
Definition: GnashKey.h:148
#define DSOEXPORT
Definition: dsodefs.h:55
int getParserDump() const
Definition: log.h:161
void processLog_aserror(const boost::format &fmt)
Definition: log.cpp:224
FileState
Definition: log.h:84
LogLevel
Definition: log.h:77
void setStamp(bool b)
Definition: log.h:165
#define GENERATE_LOG_TYPES(r, _, t)
Definition: log.h:315
int getActionDump() const
Definition: log.h:149
bool getStamp() const
Definition: log.h:169
void processLog_debug(const boost::format &fmt)
Definition: log.cpp:134
#define LOG_TYPES
Definition: log.h:270
void processLog_swferror(const boost::format &fmt)
Definition: log.cpp:213
HostFunctionReport(const char *func)
Definition: log.h:404
void processLog_unimpl(const boost::format &fmt)
Definition: log.cpp:191