24 #include <plugins/clips/aspect/clips_inifin.h> 25 #include <core/threading/thread_finalizer.h> 26 #include <logging/logger.h> 30 #include <clips/clips.h> 43 CLIPSLogger(Logger *logger)
48 void log(
const char *str)
50 if (strcmp(str,
"\n") == 0) {
51 logger_->log_info(
"CLIPS",
"%s", buffer_.c_str());
64 log_router_query(
void *env,
char *logical_name)
66 if (strcmp(logical_name,
"l") == 0)
return TRUE;
67 if (strcmp(logical_name,
"stdout") == 0)
return TRUE;
72 log_router_print(
void *env,
char *logical_name,
char *str)
74 void *rc = GetEnvironmentRouterContext(env);
75 CLIPSLogger *logger =
static_cast<CLIPSLogger *
>(rc);
81 log_router_exit(
void *env,
int exit_code)
112 clips_thread =
dynamic_cast<CLIPSAspect *
>(thread);
113 if (clips_thread == NULL) {
115 "CLIPSAspect, but RTTI says it " 116 "has not. ", thread->
name());
121 struct sigaction oldact;
122 if (sigaction(SIGINT, NULL, &oldact) == 0) {
125 void *env = clips->cobj();
126 EnvAddRouterWithContext(env, (
char *)
"fawkeslog",
135 clips_thread->init_CLIPSAspect(clips);
137 sigaction(SIGINT, &oldact, NULL);
140 "SIGINT sigaction for restoration.",
149 clips_thread =
dynamic_cast<CLIPSAspect *
>(thread);
150 if (clips_thread == NULL) {
152 "CLIPSAspect, but RTTI says it " 153 "has not. ", thread->
name());
155 clips_thread->finalize_CLIPSAspect();
166 logger_ =
new CLIPSLogger(logger);
virtual void init(Thread *thread)
Initialize thread.
Fawkes library namespace.
virtual void finalize(Thread *thread)
Finalize thread.
CLIPSAspectIniFin()
Constructor.
~CLIPSAspectIniFin()
Destructor.
Thread class encapsulation of pthreads.
Thread cannot be initialized.
const char * name() const
Get name of thread.
Thread cannot be finalized.
void set_logger(Logger *logger)
Set the logger to use for logging (print to "l" output).
Thread aspect to get access to a CLIPS environment.
Aspect initializer/finalizer base class.