File tree Expand file tree Collapse file tree 6 files changed +11
-7
lines changed Expand file tree Collapse file tree 6 files changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -68,6 +68,8 @@ int Config::get_int_setting(std::string setting_name) {
6868
6969
7070std::string Config::get_str_setting (std::string setting_name) {
71+ std::string returnString;
72+
7173 try {
7274 returnString = configMap.at (setting_name);
7375 } catch (out_of_range) {
Original file line number Diff line number Diff line change @@ -13,15 +13,14 @@ class Config {
1313 std::string configRelevantString;
1414 std::string configLine;
1515 std::string key;
16- std::string returnString;
1716 size_t position;
1817 void loadConfigFileToMap ();
1918
2019public:
2120 Config ();
2221 virtual ~Config ();
23- int get_int_setting (std::string);
24- std::string get_str_setting (std::string);
22+ static int get_int_setting (std::string);
23+ static std::string get_str_setting (std::string);
2524};
2625
2726using namespace std ;
Original file line number Diff line number Diff line change 88
99#include " Manager.h"
1010#include " Worker.h"
11+ #include " Config.h"
1112/*
1213 * manager - keeps track of workers, their current status, should handle zombies (number of workers comes from config)
1314 */
1617pthread_mutex_t * mutex_pool; // separate locks for each thread
1718
1819Manager::Manager () {
19- this ->logger = Logger (" Manager" );
20+ this ->logger = Logger (Config::get_str_setting ( " log_path " ), " Manager" );
2021 // TODO Move to config file and fetch directly from there
2122 this ->worker_count = 10 ;
2223 this ->pool = (pthread_t *) calloc (worker_count, sizeof (pthread_t ));
Original file line number Diff line number Diff line change 1111
1212#include " Router.h"
1313#include " Manager.h"
14+ #include " Config.h"
1415
1516/*
1617 * router - watches the designated port and for launches a new worker for every connection
2021
2122Router::Router (int qsize, std::string port) {
2223 this ->queue_size = qsize;
23- this ->logger = Logger (" Router" );
24+ this ->logger = Logger (Config::get_str_setting ( " log_path " ), " Router" );
2425 this ->port = port;
2526 // initialize the socket
2627 this ->listening_socket_fd = this ->init_socket ();
Original file line number Diff line number Diff line change 1111
1212#include " Worker.h"
1313#include " BasicHTTP.h"
14+ #include " Config.h"
1415
1516#define HTTP_REQUEST_LENGTH 8192
1617
1920 */
2021
2122Worker::Worker (int socket_fd) {
22- this ->logger = Logger (" Worker" );
23+ this ->logger = Logger (Config::get_str_setting ( " log_path " ), " Worker" );
2324 this ->socket_fd = socket_fd;
2425}
2526
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ int main() {
1616 // Init basic classes
1717 CmdLine cmdline;
1818 Config config;
19- Logger logger (config. get_str_setting (" log_path" ), " Server" );
19+ Logger logger (Config:: get_str_setting (" log_path" ), " Server" );
2020 // "hello from server.cpp" message, to be removed
2121 logger.info (config.get_str_setting (" config_test" ));
2222
You can’t perform that action at this time.
0 commit comments