-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.cpp
More file actions
63 lines (60 loc) · 2.44 KB
/
Copy pathconfig.cpp
File metadata and controls
63 lines (60 loc) · 2.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*
* config.h
*
* Created on: 16-Sep-2016
* Author: ashish
*/
#include "config.h"
config::config(const std::string& path) { ReadConfigXML(path); }
void config::ReadConfigXML(const std::string& config) {
std::ifstream ifs(config);
Json::Reader reader;
Json::Value val;
Json::Value conSetting;
Json::Value loggerSetting;
Json::Value stratSetting;
reader.parse(ifs, val);
try {
conSetting = val["connection"];
loggerSetting = val["logger"];
stratSetting = val["strategy"];
// For connection Settings
_host = conSetting["host"].asString();
// host=conSetting.get("host","").asString();
_user = conSetting["user"].asString();
_password = conSetting["password"].asString();
_database = conSetting["database"].asString();
_logfile = loggerSetting["logfile"].asString();
_archivelogfile = loggerSetting["archivelogfile"].asString();
_vollogfile = loggerSetting["vollogfile"].asString();
spdlog::set_async_mode(ASYNC_SIZE);
logger = spdlog::daily_logger_st("file_logger", _logfile);
archivelogger = spdlog::daily_logger_st("archive_logger", _archivelogfile);
vollogger = spdlog::daily_logger_st("vol_logger", _vollogfile);
spdlog::set_level(spdlog::level::info);
logger->set_pattern("%v");
archivelogger->set_pattern("%v");
vollogger->set_pattern("%v");
// Parse Data Configuration
_esteeID = stratSetting["esteeid"].asString();
_startdate = btime::time_from_string(stratSetting["startdate"].asString());
_enddate = btime::time_from_string(stratSetting["enddate"].asString());
std::cout << _startdate << ":" << _enddate << std::endl;
} catch (const Json::Exception& e) {
std::cout << e.what() << std::endl;
} catch (const std::exception& e) {
std::cout << e.what();
} catch (const boost::exception& e) {
std::cout << "Error parsing date";
}
}
std::string config::user() const { return _user; }
std::string config::password() const { return _password; }
std::string config::host() const { return _host; }
std::string config::database() const { return _database; }
std::string config::esteeID() const { return _esteeID; }
btime::ptime config::startdate() const { return _startdate; }
btime::ptime config::enddate() const { return _enddate; }
std::shared_ptr<spdlog::logger> config::log() { return logger; }
std::shared_ptr<spdlog::logger> config::archivelog() { return archivelogger; }
std::shared_ptr<spdlog::logger> config::vollog() { return vollogger; }