loggingmanager.hpp 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. #ifdef LOGGINGMANAGER_EXPORTS
  21. #define LOGGINGMANAGER_API DECL_EXPORT
  22. #else
  23. #define LOGGINGMANAGER_API DECL_IMPORT
  24. #endif
  25. class CEspLogEntry : implements IEspLogEntry, public CInterface
  26. {
  27. Owned<IEspContext> espContext;
  28. StringAttr option, logContent, backEndReq, backEndResp, userResp, logDatasets;
  29. Owned<IPropertyTree> userContextTree;
  30. Owned<IPropertyTree> userRequestTree;
  31. Owned<IPropertyTree> logInfoTree;
  32. Owned<IInterface> extraLog;
  33. public:
  34. IMPLEMENT_IINTERFACE;
  35. CEspLogEntry(void) { };
  36. void setOwnEspContext(IEspContext* ctx) { espContext.setown(ctx); };
  37. void setOwnUserContextTree(IPropertyTree* tree) { userContextTree.setown(tree); };
  38. void setOwnUserRequestTree(IPropertyTree* tree) { userRequestTree.setown(tree); };
  39. void setOwnLogInfoTree(IPropertyTree* tree) { logInfoTree.setown(tree); };
  40. void setOwnExtraLog(IInterface* extra) { extraLog.setown(extra); };
  41. void setOption(const char* ptr) { option.set(ptr); };
  42. void setLogContent(const char* ptr) { logContent.set(ptr); };
  43. void setBackEndReq(const char* ptr) { backEndReq.set(ptr); };
  44. void setBackEndResp(const char* ptr) { backEndResp.set(ptr); };
  45. void setUserResp(const char* ptr) { userResp.set(ptr); };
  46. void setLogDatasets(const char* ptr) { logDatasets.set(ptr); };
  47. IEspContext* getEspContext() { return espContext; };
  48. IPropertyTree* getUserContextTree() { return userContextTree; };
  49. IPropertyTree* getUserRequestTree() { return userRequestTree; };
  50. IPropertyTree* getLogInfoTree() { return logInfoTree; };
  51. IInterface* getExtraLog() { return extraLog; };
  52. const char* getOption() { return option.get(); };
  53. const char* getLogContent() { return logContent.get(); };
  54. const char* getBackEndReq() { return backEndReq.get(); };
  55. const char* getBackEndResp() { return backEndResp.get(); };
  56. const char* getUserResp() { return userResp.get(); };
  57. const char* getLogDatasets() { return logDatasets.get(); };
  58. };
  59. class CLoggingManager : implements ILoggingManager, public CInterface
  60. {
  61. typedef std::vector<IUpdateLogThread*> LOGGING_AGENTTHREADS;
  62. LOGGING_AGENTTHREADS loggingAgentThreads;
  63. bool initialized;
  64. IEspLogAgent* loadLoggingAgent(const char* name, const char* dll, const char* type, IPropertyTree* cfg);
  65. bool updateLogImpl(IEspUpdateLogRequestWrap& req, IEspUpdateLogResponse& resp);
  66. bool updateLog(IEspContext* espContext, IEspUpdateLogRequestWrap& req, IEspUpdateLogResponse& resp, StringBuffer& status);
  67. bool updateLog(IEspContext* espContext, const char* option, IPropertyTree* userContext, IPropertyTree* userRequest,
  68. const char* backEndReq, const char* backEndResp, const char* userResp, const char* logDatasets, StringBuffer& status);
  69. bool updateLog(IEspContext* espContext, const char* option, const char* logContent, StringBuffer& status);
  70. bool updateLog(IEspContext* espContext, const char* option, IPropertyTree* logInfo, IInterface* extraLog, StringBuffer& status);
  71. public:
  72. IMPLEMENT_IINTERFACE;
  73. CLoggingManager(void) { initialized = false; };
  74. virtual ~CLoggingManager(void);
  75. virtual bool init(IPropertyTree* cfg, const char* service);
  76. virtual IEspLogEntry* createLogEntry();
  77. virtual bool updateLog(IEspContext* espContext, IEspUpdateLogRequestWrap& req, IEspUpdateLogResponse& resp);
  78. virtual bool updateLog(IEspLogEntry* entry, StringBuffer& status);
  79. virtual bool getTransactionSeed(StringBuffer& transactionSeed, StringBuffer& status);
  80. virtual bool getTransactionSeed(IEspGetTransactionSeedRequest& req, IEspGetTransactionSeedResponse& resp);
  81. virtual bool getTransactionID(StringAttrMapping* transFields, StringBuffer& transactionID, StringBuffer& status);
  82. };
  83. #endif // !defined(__LOGGINGMANAGER_HPP__)