ReFRACtor
logger.cc
Go to the documentation of this file.
1 #include "logger.h"
2 #include "fp_exception.h"
3 
4 using namespace FullPhysics;
5 
6 using namespace FullPhysics;
7 #ifdef HAVE_LUA
8 #include "register_lua.h"
10 .enum_("log_level")
11 [
12  luabind::value("DEBUG", LogImp::DEBUG),
14  luabind::value("WARNING", LogImp::WARNING),
15  luabind::value("ERROR", LogImp::ERROR),
17 ]
19 
20 
21 typedef void (*f1)(const boost::shared_ptr<LogImp>& imp);
23 .scope
24 [
25  luabind::def("set_implementation", ((f1) &Logger::set_implementation))
26 ]
28 #endif
29 
30 
31 //-----------------------------------------------------------------------
33 //-----------------------------------------------------------------------
34 
36 {
37  static Logger l;
38  return l;
39 }
40 
41 //-----------------------------------------------------------------------
43 //-----------------------------------------------------------------------
44 
45 void LogImp::write(log_level l, const std::string& v)
46 {
47  os << v;
48  if(v.find("\n") != std::string::npos)
49  flush(l);
50 }
51 
52 extern "C" {
53  void lg_write_log_wrap(const int* level, const char* s, const int* s_len);
54 }
55 
56 void lg_write_log_wrap(const int* level, const char* s, const int* s_len)
57 {
58  Logger::log(LogImp::log_level(*level)) << std::string(s,*s_len) << "\n";
59 
60  // Throw exception here since a FATAL from fortran code really indicates
61  // that codes should have ended
62  if (*level == LogImp::FATAL)
63  throw Exception(std::string(s,*s_len));
64 }
void write(log_level l, const T &v)
Definition: logger.h:15
const Unit s("s", 1.0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0)
Definition: doxygen.h:52
void lg_write_log_wrap(const int *level, const char *s, const int *s_len)
Definition: logger.cc:56
This is the base of the exception hierarchy for Full Physics code.
Definition: fp_exception.h:16
The actual implementation of the Logger.
Definition: logger.h:11
#define REGISTER_LUA_CLASS(X)
Definition: register_lua.h:116
This is a simple logger.
Definition: logger.h:69
static Logger & instance()
The logger instance.
Definition: logger.cc:35
Contains classes to abstract away details in various Spurr Radiative Transfer software.
Definition: doxygen_python.h:1
#define REGISTER_LUA_END()
Definition: register_lua.h:134
def(luabind::constructor< int >()) .def("rows"
static LogHelper log(LogImp::log_level l)
Definition: logger.h:106
double value(const FullPhysics::AutoDerivative< double > &Ad)

Copyright © 2017, California Institute of Technology.
ALL RIGHTS RESERVED.
U.S. Government Sponsorship acknowledged.
Generated Fri Aug 24 2018 15:44:11