--- /dev/null
+
+/*] 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 <fstream>
+
+#include "log.hh"
+#include "script.hh"
+
+
+namespace moof {
+
+
+enum log::level log::gLevel = log::info;
+
+
+void log::level(enum level level)
+{
+ gLevel = level;
+}
+
+enum log::level log::level()
+{
+ return gLevel;
+}
+
+
+std::ostream& log(std::clog);
+
+static std::ofstream null_log_;
+std::ostream& null_log(null_log_);
+
+class log log_error( log::error, " error: ");
+class log log_warning(log::warning, "warning: ");
+class log log_info( log::info, " info: ");
+
+
+static int log_script(script& script, enum log::level level)
+{
+ static class log* logs[] = {0, &log_error, &log_warning, &log_info};
+
+ script::slot param = script[1];
+
+ while (!param.is_none())
+ {
+ (*logs[level])(param);
+ ++param.index;
+ }
+
+ return 0;
+}
+
+void log::import(script& script)
+{
+ script.import_function("LogError",
+ boost::bind(log_script, _1, log::error));
+ script.import_function("LogWarning",
+ boost::bind(log_script, _1, log::warning));
+ script.import_function("LogInfo",
+ boost::bind(log_script, _1, log::info));
+ script.import_function("print",
+ boost::bind(log_script, _1, log::info));
+}
+
+
+} // namespace moof
+