Fawkes API
Fawkes Development Version
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
All
Classes
Namespaces
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Groups
Pages
fawkes_logger.cpp
1
2
/***************************************************************************
3
* fawkes_logger.cpp - External predicates that allow the usage of the Logger
4
*
5
* Created: Wed Jul 22 11:25:21 2009
6
* Copyright 2009 Daniel Beck
7
*
8
****************************************************************************/
9
10
/* This program is free software; you can redistribute it and/or modify
11
* it under the terms of the GNU General Public License as published by
12
* the Free Software Foundation; either version 2 of the License, or
13
* (at your option) any later version.
14
*
15
* This program is distributed in the hope that it will be useful,
16
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
* GNU Library General Public License for more details.
19
*
20
* Read the full text in the LICENSE.GPL file in the doc directory.
21
*/
22
23
#include "fawkes_logger.h"
24
#include <plugins/readylogagent/eclipse_thread.h>
25
26
#include <logging/logger.h>
27
#include <core/exception.h>
28
29
#include <eclipseclass.h>
30
31
#include <cstring>
32
#include <cstdio>
33
34
int
35
p_log()
36
{
37
// log(+LogLevel, +LogString)
38
39
fawkes::Logger
*
logger
;
40
try
41
{
42
logger =
EclipseAgentThread::instance
()->
get_logger
();
43
}
44
catch
(
fawkes::Exception
& e )
45
{
46
e.
print_trace
();
47
return
EC_fail;
48
}
49
50
EC_atom log_level;
51
if
( EC_succeed != EC_arg( 1 ).is_atom( &log_level ) )
52
{
53
printf(
"Could not obtain log level\n"
);
54
return
EC_fail;
55
}
56
57
fawkes::Logger::LogLevel
ll;
58
if
( 0 == strcmp(
"ll_debug"
, log_level.name() ) )
59
{
60
ll =
fawkes::Logger::LL_DEBUG
;
61
}
62
else
if
( 0 == strcmp(
"ll_info"
, log_level.name() ) )
63
{
64
ll =
fawkes::Logger::LL_INFO
;
65
}
66
else
if
( 0 == strcmp(
"ll_warn"
, log_level.name() ) )
67
{
68
ll =
fawkes::Logger::LL_WARN
;
69
}
70
else
if
( 0 == strcmp(
"ll_error"
, log_level.name() ) )
71
{
72
ll =
fawkes::Logger::LL_ERROR
;
73
}
74
else
75
{
76
printf(
"Unknown log level %s\n"
, log_level.name() );
77
return
EC_fail;
78
}
79
80
char
* log_string;
81
if
( EC_succeed != EC_arg( 2 ).is_string( &log_string ) )
82
{
83
printf(
"Could not get 2nd argument of log/2\n"
);
84
return
EC_fail;
85
}
86
87
logger->
log
( ll,
"ReadylogAgent"
, log_string );
88
89
return
EC_succeed;
90
}
src
plugins
readylogagent
externals
fawkes_logger.cpp
Generated by
1.8.1.1