Page tree
Skip to end of metadata
Go to start of metadata

Enabling logging

To enable logging in FireBreath, both for your own messages and the ones FireBreath generates, you need to do the following:

  1. add the following to your PluginConfig.cmake

  2. regenerate your project using the prep* scripts
  3. open up Factory.cpp in your project. You need to define the following function inside the class definition for PluginFactory:

    void getLoggingMethods( FB::Log::LogMethodList& outMethods )
    	// The next line will enable logging to the console (think: printf).
    	outMethods.push_back(std::make_pair(FB::Log::LogMethod_Console, std::string()));
    	// The next line will enable logging to a logfile.
    	outMethods.push_back(std::make_pair(FB::Log::LogMethod_File, "/foo/bar/baz.log"));
    	// Obviously, if you use both lines, you will get output on both sinks.
  4. FireBreath will now log to the specified output. You can add your own log messages, by using the FBLOG_* macros that can be found in firebreath/src/ScriptingCore/logging.h.

    void something(){
    	FBLOG_INFO("something()", "Stuff did not break yet!");

About log levels

The log levels are defined in firebreath/src/ScriptingCore/logging.h:

namespace FB { namespace Log {
enum LogLevel {
    // All log messages, no matter how small
    LogLevel_Trace  = 0x01,
    // Debug level log messages - messages you won't care about unless you're debugging
    LogLevel_Debug  = 0x02,
    // Informational log messages - not critical to know, but you might care
    LogLevel_Info   = 0x04,
    // Only log warning and worse messages
    LogLevel_Warn   = 0x08,
    // Only log messages that are actual errors
    LogLevel_Error  = 0x10

By default the log level is Info, meaning Trace and Debug messages will not be emitted.

If you want to change the log level, you need to define the following inside the class definition for PluginFactory:

// Example
FB::Log::LogLevel getLogLevel(){
	return FB::Log::LogLevel_Debug; // Now Debug and above is logged.


On Mac OS X launching a web browser from the GUI will make stdout, and hence your console log messages, go to /var/log/system.log.

On Windows, LogMethod_Console logs to the system debug console.  This can be accessed with a tool such as Sysinternal's Debug View.

  • No labels


  1. Unknown User (lindaojiang)

    use log4cplus FB::Log::LogMethod_File write log to file with unicode std::wstring must add

    outMethods.push_back(std::make_pair(FB::Log::LogMethod_File, "/foo/bar/baz.log"));

    std::locale::global(std::locale("", std::locale::all ^ std::locale::numeric)); //support unicode and number has not a comma

    if add like std::locale::global(std::locale("chs"));  will get an error

    ReferenceError: invalid assignment left-hand side  window.__FB_CALL_314,458,564 = function(delay, f, args, fname) {   if (arguments...

    from browser console

    can't alert pop-up window plugin loaded!

    Is there a better suggestion?


    1. This is not the place to ask for help.  Ask for help on the google group (firebreath-dev) or on