mirror of
https://github.com/OpenNebula/one.git
synced 2025-01-21 18:03:38 +03:00
Added DEBUG_LEVEL to oned.conf. Task for ticket #5.
git-svn-id: http://svn.opennebula.org/trunk@3 3034c82b-c49b-4eb3-8279-a7acafdc01c0
This commit is contained in:
parent
6eb9fed97d
commit
3db8342e8f
@ -28,7 +28,10 @@ using namespace std;
|
||||
class HostTemplate : public TemplateSQL
|
||||
{
|
||||
public:
|
||||
HostTemplate(int tid = -1):TemplateSQL(table,tid,true){};
|
||||
HostTemplate(int tid = -1,
|
||||
const char separator = '^'):
|
||||
TemplateSQL(table,tid,true,separator)
|
||||
{};
|
||||
|
||||
~HostTemplate(){};
|
||||
|
||||
|
@ -37,7 +37,8 @@ public:
|
||||
const char *,
|
||||
const MessageType,
|
||||
const ostringstream&,
|
||||
const char *);
|
||||
const char *,
|
||||
const MessageType);
|
||||
|
||||
Log(const string& file_name,
|
||||
const MessageType level = WARNING,
|
||||
@ -58,7 +59,7 @@ public:
|
||||
private:
|
||||
|
||||
static const char error_names[];
|
||||
|
||||
|
||||
MessageType log_level;
|
||||
|
||||
ofstream file;
|
||||
|
@ -36,7 +36,7 @@
|
||||
class Nebula
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
static Nebula& instance()
|
||||
{
|
||||
static Nebula nebulad;
|
||||
@ -45,18 +45,19 @@ public:
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// Loggging
|
||||
// Logging
|
||||
// ---------------------------------------------------------------
|
||||
|
||||
static void log(
|
||||
const char * module,
|
||||
const Log::MessageType type,
|
||||
const ostringstream& message,
|
||||
const char * filename = 0)
|
||||
const char * filename = 0,
|
||||
Log::MessageType clevel = Log::ERROR)
|
||||
{
|
||||
static Log nebula_log(filename,Log::DEBUG,ios_base::trunc);
|
||||
static pthread_mutex_t log_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
static Log nebula_log(filename,clevel,ios_base::trunc);
|
||||
static pthread_mutex_t log_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
pthread_mutex_lock(&log_mutex);
|
||||
nebula_log.log(module,type,message);
|
||||
pthread_mutex_unlock(&log_mutex);
|
||||
|
@ -39,6 +39,25 @@ public:
|
||||
|
||||
return Template::get(_name,values);
|
||||
};
|
||||
|
||||
void get(
|
||||
const char * name,
|
||||
string& values) const
|
||||
{
|
||||
string _name(name);
|
||||
|
||||
Template::get(_name,values);
|
||||
};
|
||||
|
||||
|
||||
void get(
|
||||
const char * name,
|
||||
int& values) const
|
||||
{
|
||||
string _name(name);
|
||||
|
||||
Template::get(_name,values);
|
||||
};
|
||||
|
||||
private:
|
||||
friend class Nebula;
|
||||
|
@ -54,9 +54,10 @@ public:
|
||||
const char * module,
|
||||
const Log::MessageType type,
|
||||
const ostringstream& message,
|
||||
const char * filename = 0)
|
||||
const char * filename = 0,
|
||||
Log::MessageType clevel = Log::ERROR)
|
||||
{
|
||||
static Log scheduler_log(filename,Log::DEBUG);
|
||||
static Log scheduler_log(filename,clevel);
|
||||
static pthread_mutex_t log_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
pthread_mutex_lock(&log_mutex);
|
||||
|
@ -122,7 +122,7 @@ public:
|
||||
ostringstream oss;
|
||||
|
||||
oss << "SQL command was: " << c_str << ", error: " << err_msg;
|
||||
log("ONE",Log::ERROR,oss,0);
|
||||
log("ONE",Log::ERROR,oss,0,Log::ERROR);
|
||||
|
||||
sqlite3_free(err_msg);
|
||||
}
|
||||
|
@ -38,7 +38,10 @@ class Template
|
||||
{
|
||||
public:
|
||||
|
||||
Template(bool _replace_mode=false):replace_mode(_replace_mode){};
|
||||
Template(bool _replace_mode = false,
|
||||
const char _separator = '='):
|
||||
replace_mode(_replace_mode),
|
||||
separator(_separator){};
|
||||
|
||||
/**
|
||||
* The class destructor frees all the attributes conforming the template
|
||||
@ -131,6 +134,11 @@ private:
|
||||
* Mutex to perform just one flex-bison parsing at a time
|
||||
*/
|
||||
static pthread_mutex_t mutex;
|
||||
|
||||
/**
|
||||
* Character to separate key from value when dump onto a string
|
||||
**/
|
||||
char separator;
|
||||
};
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
@ -37,8 +37,9 @@ public:
|
||||
TemplateSQL(
|
||||
const char * _table,
|
||||
int template_id = -1,
|
||||
bool replace = false):
|
||||
Template(replace),table(_table),id(template_id)
|
||||
bool replace = false,
|
||||
const char separator = '='):
|
||||
Template(replace,separator),table(_table),id(template_id)
|
||||
{};
|
||||
|
||||
virtual ~TemplateSQL(){};
|
||||
|
@ -39,3 +39,8 @@ VM_MAD=[name="one_vmm",executable="bin/one_vmm_xen",owner="oneadmin",default="et
|
||||
# Port where oned will listen for xmlrpc calls.
|
||||
PORT=2633
|
||||
|
||||
|
||||
# ###########
|
||||
# DEBUG LEVEL [0=ERROR,1=WARNING,2=INFO,3=DEBUG]
|
||||
# ###########
|
||||
DEBUG_LEVEL=2
|
||||
|
@ -41,6 +41,9 @@ void Nebula::start()
|
||||
sigset_t mask;
|
||||
int signal;
|
||||
|
||||
const SingleAttribute * sattr;
|
||||
vector<const Attribute *> attr;
|
||||
|
||||
nl = getenv("ONE_LOCATION");
|
||||
|
||||
if (nl == 0)
|
||||
@ -50,23 +53,6 @@ void Nebula::start()
|
||||
|
||||
nebula_location = nl;
|
||||
|
||||
// -----------------------------------------------------------
|
||||
// Log system
|
||||
// -----------------------------------------------------------
|
||||
|
||||
try
|
||||
{
|
||||
string log_fname;
|
||||
|
||||
log_fname = nebula_location + "/var/oned.log";
|
||||
|
||||
Nebula::log("ONE",Log::INFO,"Init Log system",log_fname.c_str());
|
||||
}
|
||||
catch(runtime_error&)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------
|
||||
// Configuration
|
||||
// -----------------------------------------------------------
|
||||
@ -79,14 +65,64 @@ void Nebula::start()
|
||||
{
|
||||
throw runtime_error("Could not load nebula configuration file.");
|
||||
}
|
||||
|
||||
|
||||
// -----------------------------------------------------------
|
||||
// Log system
|
||||
// -----------------------------------------------------------
|
||||
|
||||
ostringstream os;
|
||||
|
||||
try
|
||||
{
|
||||
string log_fname;
|
||||
int log_level_int;
|
||||
log_fname = nebula_location + "/var/oned.log";
|
||||
Log::MessageType clevel = Log::ERROR;
|
||||
|
||||
nebula_configuration->get("DEBUG_LEVEL", log_level_int);
|
||||
|
||||
if (0 <= log_level_int && log_level_int <= 3 )
|
||||
{
|
||||
clevel = static_cast<Log::MessageType>(log_level_int);
|
||||
}
|
||||
|
||||
os << "Init OpenNEbula Log system";
|
||||
|
||||
// Initializing ONE Daemon log system
|
||||
|
||||
Nebula::log("ONE",
|
||||
Log::INFO,
|
||||
os,
|
||||
log_fname.c_str(),
|
||||
clevel);
|
||||
|
||||
os.str("");
|
||||
os << "Log Level: " << clevel << " [0=ERROR,1=WARNING,2=INFO,3=DEBUG]";
|
||||
|
||||
// Initializing ONE Daemon log system
|
||||
|
||||
Nebula::log("ONE",
|
||||
Log::INFO,
|
||||
os,
|
||||
log_fname.c_str(),
|
||||
clevel);
|
||||
|
||||
|
||||
}
|
||||
catch(runtime_error&)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
|
||||
Nebula::log("ONE",Log::INFO,"----------------------------------------------");
|
||||
Nebula::log("ONE",Log::INFO," OpenNEbula Configuration File ");
|
||||
Nebula::log("ONE",Log::INFO,"----------------------------------------------");
|
||||
|
||||
os.str("");
|
||||
|
||||
os << "\n--------------------------------------------";
|
||||
os << *nebula_configuration;
|
||||
os << "\n--------------------------------------------";
|
||||
|
||||
Nebula::log("ONE",Log::INFO,os);
|
||||
|
||||
@ -150,8 +186,6 @@ void Nebula::start()
|
||||
|
||||
MadManager::mad_manager_system_init();
|
||||
|
||||
const SingleAttribute * sattr;
|
||||
vector<const Attribute *> attr;
|
||||
time_t timer_period;
|
||||
istringstream is;
|
||||
|
||||
@ -354,7 +388,7 @@ void Nebula::start()
|
||||
im->finalize();
|
||||
rm->finalize();
|
||||
|
||||
//sleep to wait drviers???
|
||||
//sleep to wait drivers???
|
||||
|
||||
pthread_join(vmm->get_thread_id(),0);
|
||||
pthread_join(lcm->get_thread_id(),0);
|
||||
|
@ -74,6 +74,12 @@ NebulaTemplate::NebulaTemplate(string& nebula_location)
|
||||
|
||||
attribute = new SingleAttribute("VM_RDIR",value);
|
||||
conf_default.insert(make_pair(attribute->name(),attribute));
|
||||
|
||||
//DEBUG_LEVEL
|
||||
value = Log::WARNING;
|
||||
|
||||
attribute = new SingleAttribute("DEBUG_LEVEL",value);
|
||||
conf_default.insert(make_pair(attribute->name(),attribute));
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
@ -88,7 +88,10 @@ void Scheduler::start()
|
||||
|
||||
log_fname = nebula_location + "/var/sched.log";
|
||||
|
||||
Scheduler::log("SCHED",Log::INFO,"Init Log system",log_fname.c_str());
|
||||
Scheduler::log("SCHED",
|
||||
Log::INFO,
|
||||
"Init Scheduler Log system",
|
||||
log_fname.c_str());
|
||||
}
|
||||
catch(runtime_error &)
|
||||
{
|
||||
|
@ -243,7 +243,7 @@ ostream& operator << (ostream& os, Template& t)
|
||||
{
|
||||
s = it->second->marshall();
|
||||
|
||||
os << endl << "\t" << it->first << " ^ " << *s;
|
||||
os << endl << "\t" << it->first << t.separator << *s;
|
||||
|
||||
delete s;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user