Classes | Namespaces | Defines | Functions

log.h File Reference

#include "rc.h"
#include "dsodefs.h"
#include <fstream>
#include <boost/thread/thread.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/format.hpp>
#include "gettext.h"
#include <boost/preprocessor/arithmetic/inc.hpp>
#include <boost/preprocessor/repetition/enum_params.hpp>
#include <boost/preprocessor/repetition/repeat.hpp>
#include <boost/preprocessor/repetition/repeat_from_to.hpp>
#include <boost/preprocessor/seq/for_each.hpp>

Go to the source code of this file.

Classes

class  gnash::LogFile
class  gnash::__Host_Function_Report__

Namespaces

namespace  gnash
 

Anonymous namespace for callbacks, local functions, event handlers etc.


Defines

#define DEFAULT_LOGFILE   "gnash-dbg.log"
#define _(String)   gettext (String)
#define N_(String)   gettext_noop (String)
#define LOG_ONCE(x)
#define __FUNCDNAME__   __FUNCTION__
#define TOKENIZE_FORMAT(z, n, t)   % t##n
#define TOKENIZE_ARGS(z, n, t)   BOOST_PP_COMMA_IF(n) const T##n& t##n
#define LOG_TYPES
#define LOG_TEMPLATES(z, n, data)
#define ARG_NUMBER   10
 Defines the maximum number of template arguments.
#define GENERATE_LOG_TYPES(r, _, t)   BOOST_PP_REPEAT(ARG_NUMBER, LOG_TEMPLATES, t)
#define VERBOSE_PARSE   1
#define VERBOSE_ACTION   1
#define VERBOSE_ASCODING_ERRORS   1
#define VERBOSE_MALFORMED_SWF   1
#define VERBOSE_MALFORMED_AMF   1
#define VERBOSE_NETWORKING   1
#define IF_VERBOSE_PARSE(x)
#define IF_VERBOSE_ACTION(x)
#define IF_VERBOSE_NETWORK(x)
#define IF_VERBOSE_ASCODING_ERRORS(x)
#define IF_VERBOSE_MALFORMED_SWF(x)
#define IF_VERBOSE_MALFORMED_AMF(x)
#define dummystr(x)   # x
#define dummyestr(x)   dummystr(x)
#define __FUNCTION__   __FILE__":"dummyestr(__LINE__)
#define __PRETTY_FUNCTION__   __FUNCTION__
#define GNASH_REPORT_FUNCTION   gnash::log_debug("entering")
#define GNASH_REPORT_RETURN   gnash::log_debug("returning")

Functions

void gnash::processLog_network (const boost::format &fmt)
void gnash::processLog_error (const boost::format &fmt)
void gnash::processLog_unimpl (const boost::format &fmt)
void gnash::processLog_trace (const boost::format &fmt)
void gnash::processLog_debug (const boost::format &fmt)
void gnash::processLog_action (const boost::format &fmt)
void gnash::processLog_parse (const boost::format &fmt)
void gnash::processLog_security (const boost::format &fmt)
void gnash::processLog_swferror (const boost::format &fmt)
void gnash::processLog_amferror (const boost::format &fmt)
void gnash::processLog_aserror (const boost::format &fmt)
void gnash::processLog_abc (const boost::format &fmt)
std::string gnash::hexify (const unsigned char *bytes, size_t length, bool ascii)
 Convert a sequence of bytes to hex or ascii format.

Define Documentation

#define _ (   String  )     gettext (String)
#define __FUNCDNAME__   __FUNCTION__
#define __FUNCTION__   __FILE__":"dummyestr(__LINE__)
#define __PRETTY_FUNCTION__   __FUNCTION__
#define ARG_NUMBER   10

Defines the maximum number of template arguments.

The preprocessor generates templates with 1..ARG_NUMBER arguments.

#define DEFAULT_LOGFILE   "gnash-dbg.log"
#define dummyestr (   x  )     dummystr(x)
#define dummystr (   x  )     # x
#define GENERATE_LOG_TYPES (   r,
  _,
  t 
)    BOOST_PP_REPEAT(ARG_NUMBER, LOG_TEMPLATES, t)

Calls the macro LOG_TEMPLATES an ARG_NUMBER number of times, each time adding an extra typename argument to the template.

#define GNASH_REPORT_FUNCTION   gnash::log_debug("entering")
#define GNASH_REPORT_RETURN   gnash::log_debug("returning")
#define IF_VERBOSE_ACTION (   x  ) 
#define IF_VERBOSE_ASCODING_ERRORS (   x  ) 
#define IF_VERBOSE_MALFORMED_AMF (   x  ) 
#define IF_VERBOSE_MALFORMED_SWF (   x  ) 
#define IF_VERBOSE_NETWORK (   x  ) 
#define IF_VERBOSE_PARSE (   x  ) 
#define LOG_ONCE (   x  ) 
Value:
{ \
    static bool warned = false; \
    if (!warned) { warned = true; x; } \
}
#define LOG_TEMPLATES (   z,
  n,
  data 
)
Value:
template<BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(n), typename T)>\
inline void log_##data(BOOST_PP_REPEAT(BOOST_PP_INC(n), TOKENIZE_ARGS, t)) \
{\
    if (LogFile::getDefaultInstance().getVerbosity() == 0) return; \
    boost::format f(t0); \
    using namespace boost::io; \
    f.exceptions(all_error_bits ^ (too_many_args_bit | \
                                   too_few_args_bit | \
                                   bad_format_string_bit)); \
    processLog_##data(f BOOST_PP_REPEAT_FROM_TO(1, \
            BOOST_PP_INC(n), \
            TOKENIZE_FORMAT, t));\
}

This actually creates the template functions using the TOKENIZE functions above. The templates look like this: template<typename T0 , typename T1 , typename T2> void log_error(const T0& t0 , const T1& t1 , const T2& t2) { if (LogFile::getDefaultInstance().getVerbosity() == 0) return; boost::format f(t0); using namespace boost::io; f.exceptions(all_error_bits ^ (too_many_args_bit | too_few_args_bit | bad_format_string_bit)); processLog_error(f % t1 % t2); }

Only not as nicely indented.

Use "g++ -E log.h" or "cpp log.h" to check.

#define LOG_TYPES
Value:
(error) (debug) (unimpl) (aserror) (swferror) \
    (amferror) (security) (action) (parse) (trace) (abc) (network)

This is a sequence of different log message types to be used in the code. Append the name to log_ to call the function, e.g. log_error, log_unimpl.

#define N_ (   String  )     gettext_noop (String)
#define TOKENIZE_ARGS (   z,
  n,
  t 
)    BOOST_PP_COMMA_IF(n) const T##n& t##n

Macro to add a number of arguments to the templated function corresponding to the number of template arguments. Produces code like this: "const T0& t0, const T1& t1, const T2& t2 ..."

#define TOKENIZE_FORMAT (   z,
  n,
  t 
)    % t##n

This heap of steaming preprocessor code magically converts printf-style statements into boost::format messages using templates. Macro to feed boost::format strings to the boost::format object, producing code like this: "% t1 % t2 % t3 ..."

#define VERBOSE_ACTION   1
#define VERBOSE_ASCODING_ERRORS   1
#define VERBOSE_MALFORMED_AMF   1
#define VERBOSE_MALFORMED_SWF   1
#define VERBOSE_NETWORKING   1
#define VERBOSE_PARSE   1