1 | /* |
2 | * Legal Notice |
3 | * |
4 | * This document and associated source code (the "Work") is a part of a |
5 | * benchmark specification maintained by the TPC. |
6 | * |
7 | * The TPC reserves all right, title, and interest to the Work as provided |
8 | * under U.S. and international laws, including without limitation all patent |
9 | * and trademark rights therein. |
10 | * |
11 | * No Warranty |
12 | * |
13 | * 1.1 TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THE INFORMATION |
14 | * CONTAINED HEREIN IS PROVIDED "AS IS" AND WITH ALL FAULTS, AND THE |
15 | * AUTHORS AND DEVELOPERS OF THE WORK HEREBY DISCLAIM ALL OTHER |
16 | * WARRANTIES AND CONDITIONS, EITHER EXPRESS, IMPLIED OR STATUTORY, |
17 | * INCLUDING, BUT NOT LIMITED TO, ANY (IF ANY) IMPLIED WARRANTIES, |
18 | * DUTIES OR CONDITIONS OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR |
19 | * PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OF |
20 | * WORKMANLIKE EFFORT, OF LACK OF VIRUSES, AND OF LACK OF NEGLIGENCE. |
21 | * ALSO, THERE IS NO WARRANTY OR CONDITION OF TITLE, QUIET ENJOYMENT, |
22 | * QUIET POSSESSION, CORRESPONDENCE TO DESCRIPTION OR NON-INFRINGEMENT |
23 | * WITH REGARD TO THE WORK. |
24 | * 1.2 IN NO EVENT WILL ANY AUTHOR OR DEVELOPER OF THE WORK BE LIABLE TO |
25 | * ANY OTHER PARTY FOR ANY DAMAGES, INCLUDING BUT NOT LIMITED TO THE |
26 | * COST OF PROCURING SUBSTITUTE GOODS OR SERVICES, LOST PROFITS, LOSS |
27 | * OF USE, LOSS OF DATA, OR ANY INCIDENTAL, CONSEQUENTIAL, DIRECT, |
28 | * INDIRECT, OR SPECIAL DAMAGES WHETHER UNDER CONTRACT, TORT, WARRANTY, |
29 | * OR OTHERWISE, ARISING IN ANY WAY OUT OF THIS OR ANY OTHER AGREEMENT |
30 | * RELATING TO THE WORK, WHETHER OR NOT SUCH AUTHOR OR DEVELOPER HAD |
31 | * ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. |
32 | * |
33 | * Contributors |
34 | * - Matt Emmerton |
35 | */ |
36 | |
37 | /****************************************************************************** |
38 | * Description: This file implements the interface for data logging. |
39 | ******************************************************************************/ |
40 | |
41 | #include <iostream> |
42 | #include <sstream> |
43 | |
44 | #include "utilities/EGenStandardTypes.h" |
45 | #include "main/DriverTypes.h" |
46 | #include "main/DriverParamSettings.h" |
47 | #include "main/BaseLogger.h" |
48 | #include "main/BaseLogFormatter.h" |
49 | |
50 | using namespace TPCE; |
51 | |
52 | char TPCE::szDriverTypeNames[eDriverMax][14] = {"EGenLoader" , "EGenDriverAll" , "EGenDriverCE" , "EGenDriverMEE" , |
53 | "EGenDriverDM" }; |
54 | |
55 | /* Constructor */ |
56 | CBaseLogger::CBaseLogger(eDriverType drvType, INT32 UniqueId, CBaseLogFormatter *pFormatter) |
57 | : m_pLogFormatter(pFormatter) { |
58 | char m_Version[32]; |
59 | |
60 | // Get EGen Version |
61 | GetEGenVersionString(m_Version, sizeof(m_Version)); |
62 | |
63 | // Generate Log Prefix String |
64 | snprintf(&m_Prefix[0], sizeof(m_Prefix), "%s (%s) %d" , szDriverTypeNames[drvType], m_Version, UniqueId); |
65 | } |
66 | |
67 | /* Methods */ |
68 | bool CBaseLogger::SendToLogger(const char *szPrefix, const char *szMsg) { |
69 | CDateTime curTime; |
70 | return SendToLoggerImpl(szPrefix, curTime.ToStr(12), szMsg); |
71 | } |
72 | |
73 | // Strings |
74 | bool CBaseLogger::SendToLogger(const char *str) { |
75 | return SendToLogger(m_Prefix, str); |
76 | } |
77 | bool CBaseLogger::SendToLogger(string str) { |
78 | return SendToLogger(str.c_str()); |
79 | } |
80 | |
81 | // Parameter Structures |
82 | bool CBaseLogger::SendToLogger(CLoaderSettings &parms) { |
83 | return SendToLogger(m_pLogFormatter->GetLogOutput(parms)); |
84 | } |
85 | bool CBaseLogger::SendToLogger(CDriverGlobalSettings &parms) { |
86 | return SendToLogger(m_pLogFormatter->GetLogOutput(parms)); |
87 | } |
88 | |
89 | bool CBaseLogger::SendToLogger(CDriverCESettings &parms) { |
90 | return SendToLogger(m_pLogFormatter->GetLogOutput(parms)); |
91 | } |
92 | |
93 | bool CBaseLogger::SendToLogger(CDriverCEPartitionSettings &parms) { |
94 | return SendToLogger(m_pLogFormatter->GetLogOutput(parms)); |
95 | } |
96 | |
97 | bool CBaseLogger::SendToLogger(CDriverMEESettings &parms) { |
98 | return SendToLogger(m_pLogFormatter->GetLogOutput(parms)); |
99 | } |
100 | |
101 | bool CBaseLogger::SendToLogger(CDriverDMSettings &parms) { |
102 | return SendToLogger(m_pLogFormatter->GetLogOutput(parms)); |
103 | } |
104 | |
105 | bool CBaseLogger::SendToLogger(CBrokerVolumeSettings &parms) { |
106 | return SendToLogger(m_pLogFormatter->GetLogOutput(parms)); |
107 | } |
108 | |
109 | bool CBaseLogger::SendToLogger(CCustomerPositionSettings &parms) { |
110 | return SendToLogger(m_pLogFormatter->GetLogOutput(parms)); |
111 | } |
112 | |
113 | bool CBaseLogger::SendToLogger(CMarketWatchSettings &parms) { |
114 | return SendToLogger(m_pLogFormatter->GetLogOutput(parms)); |
115 | } |
116 | |
117 | bool CBaseLogger::SendToLogger(CSecurityDetailSettings &parms) { |
118 | return SendToLogger(m_pLogFormatter->GetLogOutput(parms)); |
119 | } |
120 | |
121 | bool CBaseLogger::SendToLogger(CTradeLookupSettings &parms) { |
122 | return SendToLogger(m_pLogFormatter->GetLogOutput(parms)); |
123 | } |
124 | |
125 | bool CBaseLogger::SendToLogger(CTradeOrderSettings &parms) { |
126 | return SendToLogger(m_pLogFormatter->GetLogOutput(parms)); |
127 | } |
128 | |
129 | bool CBaseLogger::SendToLogger(CTradeUpdateSettings &parms) { |
130 | return SendToLogger(m_pLogFormatter->GetLogOutput(parms)); |
131 | } |
132 | |
133 | bool CBaseLogger::SendToLogger(CTxnMixGeneratorSettings &parms) { |
134 | return SendToLogger(m_pLogFormatter->GetLogOutput(parms)); |
135 | } |
136 | |
137 | bool CBaseLogger::SendToLogger(TDriverCETxnSettings &parms) { |
138 | bool result = false; |
139 | |
140 | result |= SendToLogger(m_pLogFormatter->GetLogOutput(parms.BV_settings)); |
141 | result |= SendToLogger(m_pLogFormatter->GetLogOutput(parms.CP_settings)); |
142 | result |= SendToLogger(m_pLogFormatter->GetLogOutput(parms.MW_settings)); |
143 | result |= SendToLogger(m_pLogFormatter->GetLogOutput(parms.SD_settings)); |
144 | result |= SendToLogger(m_pLogFormatter->GetLogOutput(parms.TL_settings)); |
145 | result |= SendToLogger(m_pLogFormatter->GetLogOutput(parms.TO_settings)); |
146 | result |= SendToLogger(m_pLogFormatter->GetLogOutput(parms.TU_settings)); |
147 | result |= SendToLogger(m_pLogFormatter->GetLogOutput(parms.TxnMixGenerator_settings)); |
148 | |
149 | return result; |
150 | } |
151 | |