log/global.cpp

/* This example shows how to use toast::global in relation to logging.  This
   allows for an application to configure a log that a library will use.
   Using global avoids the overhead of toast::log_handle but increases the
   coupling by requiring all parties to know the exact type of the log.
*/

#include <toast/log.hpp>
#include <toast/global.hpp>
#include "examples.hpp"

using namespace toast::log;

void global_log_example()
{
  GlobalLog &log = toast::global<GlobalLog>();
  log.message("This behaves however examples.C told it to.", DEBUG);
  log.message("Lo and behold the lovely global log!", NOTICE);
}

SourceForge.net Logo