mirror of
https://github.com/OpenNebula/one.git
synced 2025-02-03 13:47:01 +03:00
feature #1658: Move DEBUG_LEVEL and LOG_SYSTEM to the LOG section in oned.conf
This commit is contained in:
parent
32f8098f8b
commit
50160c50c7
@ -172,24 +172,59 @@ public:
|
||||
// --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns the value of DEBUG_LEVEL in oned.conf file
|
||||
* Returns the value of LOG->DEBUG_LEVEL in oned.conf file
|
||||
* @return the debug level, to instantiate Log'ers
|
||||
*/
|
||||
Log::MessageType get_debug_level() const
|
||||
{
|
||||
Log::MessageType clevel = Log::ERROR;
|
||||
int log_level_int;
|
||||
Log::MessageType clevel = Log::ERROR;
|
||||
vector<const Attribute *> logs;
|
||||
int rc;
|
||||
int log_level_int;
|
||||
|
||||
nebula_configuration->get("DEBUG_LEVEL", log_level_int);
|
||||
rc = nebula_configuration->get("LOG", logs);
|
||||
|
||||
if (0 <= log_level_int && log_level_int <= 3 )
|
||||
if ( rc != 0 )
|
||||
{
|
||||
clevel = static_cast<Log::MessageType>(log_level_int);
|
||||
string value;
|
||||
const VectorAttribute * log = static_cast<const VectorAttribute *>
|
||||
(logs[0]);
|
||||
value = log->vector_value("DEBUG_LEVEL");
|
||||
|
||||
log_level_int = atoi(value.c_str());
|
||||
|
||||
if (0 <= log_level_int && log_level_int <= 3 )
|
||||
{
|
||||
clevel = static_cast<Log::MessageType>(log_level_int);
|
||||
}
|
||||
}
|
||||
|
||||
return clevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of LOG->SYSTEM in oned.conf file
|
||||
* @return the system, either "file" or "syslog"
|
||||
*/
|
||||
string get_log_system() const
|
||||
{
|
||||
vector<const Attribute *> logs;
|
||||
int rc;
|
||||
string log_system = "file";
|
||||
|
||||
rc = nebula_configuration->get("LOG", logs);
|
||||
|
||||
if ( rc != 0 )
|
||||
{
|
||||
string value;
|
||||
const VectorAttribute * log = static_cast<const VectorAttribute *>
|
||||
(logs[0]);
|
||||
log_system = log->vector_value("SYSTEM");
|
||||
}
|
||||
|
||||
return log_system;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of ONE_LOCATION env variable. When this variable is
|
||||
* not defined the nebula location is "/".
|
||||
|
@ -37,13 +37,19 @@
|
||||
# VNC_BASE_PORT: VNC ports for VMs can be automatically set to VNC_BASE_PORT +
|
||||
# VMID
|
||||
#
|
||||
# DEBUG_LEVEL: 0 = ERROR, 1 = WARNING, 2 = INFO, 3 = DEBUG
|
||||
# LOG: Configuration for the logging system
|
||||
# SYSTEM: either "file" or "syslog".
|
||||
# DEBUG_LEVEL: 0 = ERROR, 1 = WARNING, 2 = INFO, 3 = DEBUG
|
||||
#
|
||||
# VM_SUBMIT_ON_HOLD: Forces VMs to be created on hold state instead of pending.
|
||||
# Values: YES or NO.
|
||||
#*******************************************************************************
|
||||
#
|
||||
|
||||
LOG_SYSTEM = "syslog"
|
||||
LOG = [
|
||||
# SYSTEM = "file",
|
||||
DEBUG_LEVEL = 3
|
||||
]
|
||||
|
||||
#MANAGER_TIMER = 30
|
||||
|
||||
@ -71,8 +77,6 @@ DB = [ backend = "sqlite" ]
|
||||
|
||||
VNC_BASE_PORT = 5900
|
||||
|
||||
DEBUG_LEVEL = 3
|
||||
|
||||
#VM_SUBMIT_ON_HOLD = "NO"
|
||||
|
||||
#*******************************************************************************
|
||||
|
@ -320,7 +320,7 @@ void Nebula::start()
|
||||
Log::MessageType clevel;
|
||||
string log_system;
|
||||
|
||||
nebula_configuration->get("LOG_SYSTEM", log_system);
|
||||
log_system = get_log_system();
|
||||
clevel = get_debug_level();
|
||||
|
||||
// Initializing ONE Daemon log system
|
||||
|
@ -78,6 +78,7 @@ void OpenNebulaTemplate::set_conf_default()
|
||||
SingleAttribute * attribute;
|
||||
VectorAttribute * vattribute;
|
||||
string value;
|
||||
map<string,string> vvalue;
|
||||
|
||||
// MANAGER_TIMER
|
||||
value = "15";
|
||||
@ -144,7 +145,6 @@ void OpenNebulaTemplate::set_conf_default()
|
||||
conf_default.insert(make_pair(attribute->name(),attribute));
|
||||
|
||||
//DB CONFIGURATION
|
||||
map<string,string> vvalue;
|
||||
vvalue.insert(make_pair("BACKEND","sqlite"));
|
||||
|
||||
vattribute = new VectorAttribute("DB",vvalue);
|
||||
@ -174,6 +174,12 @@ void OpenNebulaTemplate::set_conf_default()
|
||||
attribute = new SingleAttribute("VM_SUBMIT_ON_HOLD",value);
|
||||
conf_default.insert(make_pair(attribute->name(),attribute));
|
||||
|
||||
// LOG CONFIGURATION
|
||||
vvalue.clear();
|
||||
vvalue.insert(make_pair("SYSTEM","file"));
|
||||
vvalue.insert(make_pair("DEBUG_LEVEL","3"));
|
||||
vattribute = new VectorAttribute("LOG",vvalue);
|
||||
|
||||
/*
|
||||
#*******************************************************************************
|
||||
# Physical Networks configuration
|
||||
@ -245,18 +251,5 @@ void OpenNebulaTemplate::set_conf_default()
|
||||
|
||||
attribute = new SingleAttribute("DEFAULT_UMASK",value);
|
||||
conf_default.insert(make_pair(attribute->name(),attribute));
|
||||
|
||||
/*
|
||||
#*******************************************************************************
|
||||
# Log system configuration
|
||||
#*******************************************************************************
|
||||
# LOG_SYSTEM
|
||||
#*******************************************************************************
|
||||
*/
|
||||
// LOG_SYSTEM
|
||||
value = "file";
|
||||
|
||||
attribute = new SingleAttribute("LOG_SYSTEM",value);
|
||||
conf_default.insert(make_pair(attribute->name(),attribute));
|
||||
}
|
||||
|
||||
|
@ -192,9 +192,24 @@ int VirtualMachine::select(SqlDB * db)
|
||||
try
|
||||
{
|
||||
Log::MessageType clevel;
|
||||
string log_system;
|
||||
|
||||
log_system = nd.get_log_system();
|
||||
clevel = nd.get_debug_level();
|
||||
|
||||
if ( log_system == "file" )
|
||||
{
|
||||
_log = new FileLog(nd.get_vm_log_filename(oid), clevel);
|
||||
}
|
||||
else if ( log_system == "syslog" )
|
||||
{
|
||||
_log = new SysLogResource(oid, obj_type, clevel);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw('Unknown log system.');
|
||||
}
|
||||
|
||||
clevel = nd.get_debug_level();
|
||||
_log = new FileLog(nd.get_vm_log_filename(oid), clevel);
|
||||
}
|
||||
catch(exception &e)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user