summaryrefslogtreecommitdiff
path: root/src/bitz/config.cpp
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2018-06-27 16:59:39 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2018-06-27 16:59:39 +0200
commitf1187001ebc5b9ad18d5b5992c75bd682e367b42 (patch)
tree134ca05c369ac09dd7fa5f51285cc7176d62c385 /src/bitz/config.cpp
parentb84c8622d092fd773888eed89f1dbffb2c3a57f7 (diff)
parent8111b77e95b083137faf888aeb5892073adf7ab4 (diff)
Update upstream source from tag 'upstream/2.0.0'
Update to upstream version '2.0.0' with Debian dir 112f2f2cb91158baaf8ee3a1f623980b43a258ce
Diffstat (limited to 'src/bitz/config.cpp')
-rw-r--r--src/bitz/config.cpp38
1 files changed, 15 insertions, 23 deletions
diff --git a/src/bitz/config.cpp b/src/bitz/config.cpp
index aaa247f..f5ef810 100644
--- a/src/bitz/config.cpp
+++ b/src/bitz/config.cpp
@@ -18,9 +18,7 @@
*/
#include "config.h"
-#include "logger.h"
-#include <iostream>
#include <cstdlib>
@@ -32,7 +30,6 @@ namespace bitz {
_config.port = 1344;
_config.pid_file = "/dev/null";
_config.log_file = "/dev/null";
- _config.log_category = "bitz";
_config.req_handlers_count = 0;
_config.req_handlers = NULL;
@@ -44,6 +41,9 @@ namespace bitz {
// defaults
_lconfig = NULL;
+ // logger
+ _logger = spdlog::get( "bitz-server" );
+
}
Config::~Config() {
@@ -72,12 +72,10 @@ namespace bitz {
try {
config->readFile( config_file.c_str() );
} catch ( const libconfig::FileIOException &ex ) {
- std::cerr << "[config] failed to read config file: " << config_file
- << ", exception: " << ex.what() << std::endl;
+ _logger->error( "[config] failed to read config file: {}, exception: {}", config_file, ex.what() );
exit( EXIT_FAILURE );
} catch ( const libconfig::ParseException &pex ) {
- std::cerr << "[config] parse error at " << pex.getFile()
- << ":" << pex.getLine() << " - " << pex.getError() << std::endl;
+ _logger->error( "[config] parse error at {}:{} - {}", pex.getFile(), pex.getLine(), pex.getError() );
exit( EXIT_FAILURE );
}
@@ -87,7 +85,6 @@ namespace bitz {
config->lookupValue( "port", _config.port );
config->lookupValue( "pid_file", _config.pid_file );
config->lookupValue( "log_file", _config.log_file );
- config->lookupValue( "log_category", _config.log_category );
config->lookupValue( "max_workers", _config.max_workers );
config->lookupValue( "max_worker_requests", _config.max_worker_requests );
@@ -95,8 +92,7 @@ namespace bitz {
config->lookupValue( "comm_timeout", _config.comm_timeout );
} catch ( const libconfig::SettingNotFoundException &e ) {
- std::cerr << "[config] failed to load core configs, "
- << e.getPath() << " : " << e.what() << std::endl;
+ _logger->error( "[config] failed to load core configs, {} : {}", e.getPath(), e.what() );
}
// cache configs
@@ -125,12 +121,11 @@ namespace bitz {
libconfig::Setting &setting = _lconfig->lookup( std::string( "modules." ).append( module ) );
setting.lookupValue( config, config_value );
} catch ( const libconfig::SettingNotFoundException &e ) {
- // TODO: log errors ??
- std::cerr << "[config] " << e.getPath() << " : " << e.what() << std::endl;
+ _logger->error( "[config] {} : {}", e.getPath(), e.what() );
}
} else {
- std::cout << "[config] 'modules' configs not found" << std::endl;
+ _logger->info( "[config] 'modules' configs not found" );
}
return config_value;
@@ -143,16 +138,14 @@ namespace bitz {
int i, j;
std::string s;
- std::cout << "[config] looking for req_handlers... ";
+ _logger->trace( "[config] looking for req_handlers" );
if ( _lconfig->exists( "req_handlers" ) ) {
- std::cout << "found ";
-
libconfig::Setting &req_handlers = _lconfig->lookup( "req_handlers" );
_config.req_handlers_count = req_handlers.getLength();
_config.req_handlers = new req_handlers_config_t[_config.req_handlers_count];
- std::cout << "(" << _config.req_handlers_count << ")" << std::endl;
+ _logger->debug( "[config] found {} request handlers", _config.req_handlers_count );
try {
@@ -162,29 +155,28 @@ namespace bitz {
_config.req_handlers[i].class_name = (const char *) req_handlers[i]["class"];
// read request handler modules config
- std::cout << "[config] looking for " << _config.req_handlers[i].name << " modules... ";
+ _logger->debug( "[config] looking for {} modules", _config.req_handlers[i].name );
if ( req_handlers[i].exists( "modules" ) ) {
- std::cout << "found ";
_config.req_handlers[i].modules_count = req_handlers[i]["modules"].getLength();
_config.req_handlers[i].modules = new modules_config_t[_config.req_handlers[i].modules_count];
- std::cout << "(" << _config.req_handlers[i].modules_count << ")" << std::endl;
+ _logger->debug( "[config] found {} modules for {}", _config.req_handlers[i].modules_count, _config.req_handlers[i].name );
for ( j = 0; j < _config.req_handlers[i].modules_count; j++ ) {
_config.req_handlers[i].modules[j].name = (const char *) req_handlers[i]["modules"][j]["name"];
_config.req_handlers[i].modules[j].module = (const char *) req_handlers[i]["modules"][j]["module"];
}
} else {
- std::cout << "not found" << std::endl;
+ _logger->info( "[config] no modules found for {}", _config.req_handlers[i].name );
}
}
} catch ( const libconfig::SettingNotFoundException &ex ) {
- std::cerr << "[config] Error: " << ex.getPath() << ex.what() << std::endl;
+ _logger->error( "[config] {} : {}", ex.getPath(), ex.what() );
}
} else {
- std::cout << "not found" << std::endl;
+ _logger->info( "[config] no request handlers found" );
}
}