/*] Copyright (c) 2009-2010, Charles McGarvey [************************** **] All rights reserved. * * vi:ts=4 sw=4 tw=75 * * Distributable under the terms and conditions of the 2-clause BSD license; * see the file COPYING for a complete text of the license. * **************************************************************************/ #include #include "Log.hh" #include "Script.hh" namespace Mf { Log::Level Log::gLevel = Log::INFO; void Log::setLevel(Level level) { gLevel = level; } Log::Level Log::getLevel() { return gLevel; } std::ostream& log(std::clog); static std::ofstream nullLog_; std::ostream& nullLog(nullLog_); Log logError(Log::ERRORR, " error: "); Log logWarning(Log::WARNING, "warning: "); Log logInfo(Log::INFO, " info: "); static int logScript_(Script& script, Log::Level level) { static Log* logs[] = {0, &logError, &logWarning, &logInfo}; Script::Slot param = script[1]; while (!param.isNone()) { (*logs[level])(param); ++param.index; } return 0; } void importLogFunctions(Script& script) { script.importFunction("LogError", boost::bind(logScript_, _1, Log::ERRORR)); script.importFunction("LogWarning", boost::bind(logScript_, _1, Log::WARNING)); script.importFunction("LogInfo", boost::bind(logScript_, _1, Log::INFO)); script.importFunction("print", boost::bind(logScript_, _1, Log::INFO)); } } // namespace Mf