loggingmanager.hpp 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /*##############################################################################
  2. HPCC SYSTEMS software Copyright (C) 2014 HPCC Systems.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. ############################################################################## */
  13. #if !defined(__LOGGINGMANAGER_HPP__)
  14. #define __LOGGINGMANAGER_HPP__
  15. #include <vector>
  16. #include "loggingcommon.hpp"
  17. #include "loggingagentbase.hpp"
  18. #include "logthread.hpp"
  19. #include "loggingmanager.h"
  20. #include "LogFailSafe.hpp"
  21. #ifdef LOGGINGMANAGER_EXPORTS
  22. #define LOGGINGMANAGER_API DECL_EXPORT
  23. #else
  24. #define LOGGINGMANAGER_API DECL_IMPORT
  25. #endif
  26. class CEspLogEntry : implements IEspLogEntry, public CInterface
  27. {
  28. Owned<IEspContext> espContext;
  29. StringAttr option, logContent, backEndReq, backEndResp, userResp, logDatasets;
  30. Owned<IPropertyTree> userContextTree;
  31. Owned<IPropertyTree> userRequestTree;
  32. Owned<IPropertyTree> logInfoTree;
  33. Owned<IInterface> extraLog;
  34. public:
  35. IMPLEMENT_IINTERFACE;
  36. CEspLogEntry(void) { };
  37. void setOwnEspContext(IEspContext* ctx) { espContext.setown(ctx); };
  38. void setOwnUserContextTree(IPropertyTree* tree) { userContextTree.setown(tree); };
  39. void setOwnUserRequestTree(IPropertyTree* tree) { userRequestTree.setown(tree); };
  40. void setOwnLogInfoTree(IPropertyTree* tree) { logInfoTree.setown(tree); };
  41. void setOwnExtraLog(IInterface* extra) { extraLog.setown(extra); };
  42. void setOption(const char* ptr) { option.set(ptr); };
  43. void setLogContent(const char* ptr) { logContent.set(ptr); };
  44. void setBackEndReq(const char* ptr) { backEndReq.set(ptr); };
  45. void setBackEndResp(const char* ptr) { backEndResp.set(ptr); };
  46. void setUserResp(const char* ptr) { userResp.set(ptr); };
  47. void setLogDatasets(const char* ptr) { logDatasets.set(ptr); };
  48. IEspContext* getEspContext() { return espContext; };
  49. IPropertyTree* getUserContextTree() { return userContextTree; };
  50. IPropertyTree* getUserRequestTree() { return userRequestTree; };
  51. IPropertyTree* getLogInfoTree() { return logInfoTree; };
  52. IInterface* getExtraLog() { return extraLog; };
  53. const char* getOption() { return option.get(); };
  54. const char* getLogContent() { return logContent.get(); };
  55. const char* getBackEndReq() { return backEndReq.get(); };
  56. const char* getBackEndResp() { return backEndResp.get(); };
  57. const char* getUserResp() { return userResp.get(); };
  58. const char* getLogDatasets() { return logDatasets.get(); };
  59. };
  60. class CLoggingManager : implements ILoggingManager, public CInterface
  61. {
  62. typedef std::vector<IUpdateLogThread*> LOGGING_AGENTTHREADS;
  63. LOGGING_AGENTTHREADS loggingAgentThreads;
  64. bool oneTankFile = false, decoupledLogging = false, initialized = false;
  65. Owned<ILogFailSafe> logFailSafe;
  66. CLogContentFilter logContentFilter;
  67. IEspLogAgent* loadLoggingAgent(const char* name, const char* dll, const char* type, IPropertyTree* cfg);
  68. bool updateLogImpl(IEspUpdateLogRequestWrap& req, IEspUpdateLogResponse& resp);
  69. bool saveToTankFile(IEspUpdateLogRequestWrap& req, CLogRequestInFile* reqInFile);
  70. unsigned serializeLogRequestContent(IEspUpdateLogRequestWrap* request, const char* GUID, StringBuffer& logData);
  71. bool updateLog(IEspContext* espContext, IEspUpdateLogRequestWrap& req, IEspUpdateLogResponse& resp, StringBuffer& status);
  72. bool updateLog(IEspContext* espContext, const char* option, IPropertyTree* userContext, IPropertyTree* userRequest,
  73. const char* backEndReq, const char* backEndResp, const char* userResp, const char* logDatasets, StringBuffer& status);
  74. bool updateLog(IEspContext* espContext, const char* option, const char* logContent, StringBuffer& status);
  75. bool updateLog(IEspContext* espContext, const char* option, IPropertyTree* logInfo, IInterface* extraLog, StringBuffer& status);
  76. public:
  77. IMPLEMENT_IINTERFACE;
  78. CLoggingManager(void) { initialized = false; };
  79. virtual ~CLoggingManager(void);
  80. virtual bool init(IPropertyTree* cfg, const char* service);
  81. virtual IEspLogEntry* createLogEntry();
  82. virtual bool updateLog(IEspContext* espContext, IEspUpdateLogRequestWrap& req, IEspUpdateLogResponse& resp);
  83. virtual bool updateLog(IEspLogEntry* entry, StringBuffer& status);
  84. virtual bool getTransactionSeed(StringBuffer& transactionSeed, StringBuffer& status);
  85. virtual bool getTransactionSeed(IEspGetTransactionSeedRequest& req, IEspGetTransactionSeedResponse& resp);
  86. virtual bool getTransactionID(StringAttrMapping* transFields, StringBuffer& transactionID, StringBuffer& status);
  87. };
  88. #endif // !defined(__LOGGINGMANAGER_HPP__)