logging.cpp 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*##############################################################################
  2. HPCC SYSTEMS software Copyright (C) 2012 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. #include <time.h>
  14. #include <stdlib.h>
  15. #include <string.h>
  16. #include <ctype.h>
  17. #include "logging.hpp"
  18. #include "jlog.hpp"
  19. #define LOGGING_VERSION "LOGGING 1.0.1"
  20. static const char * compatibleVersions[] = {
  21. "LOGGING 1.0.0 [66aec3fb4911ceda247c99d6a2a5944c]", // linux version
  22. LOGGING_VERSION,
  23. NULL };
  24. static const char * EclDefinition =
  25. "export Logging := SERVICE\n"
  26. " dbglog(const string src) : c,action,entrypoint='logDbgLog'; \n"
  27. " addWorkunitInformation(const varstring txt, unsigned code=0, unsigned severity=0, const varstring source='user') : ctxmethod,action,entrypoint='addWuException'; \n"
  28. " addWorkunitWarning(const varstring txt, unsigned code=0, unsigned severity=1, const varstring source='user') : ctxmethod,action,entrypoint='addWuException'; \n"
  29. " addWorkunitError(const varstring txt, unsigned code=0, unsigned severity=2, const varstring source='user') : ctxmethod,action,entrypoint='addWuException'; \n"
  30. "END;";
  31. LOGGING_API bool getECLPluginDefinition(ECLPluginDefinitionBlock *pb)
  32. {
  33. if (pb->size == sizeof(ECLPluginDefinitionBlockEx))
  34. {
  35. ECLPluginDefinitionBlockEx * pbx = (ECLPluginDefinitionBlockEx *) pb;
  36. pbx->compatibleVersions = compatibleVersions;
  37. }
  38. else if (pb->size != sizeof(ECLPluginDefinitionBlock))
  39. return false;
  40. pb->magicVersion = PLUGIN_VERSION;
  41. pb->version = LOGGING_VERSION;
  42. pb->moduleName = "lib_logging";
  43. pb->ECL = EclDefinition;
  44. pb->flags = PLUGIN_IMPLICIT_MODULE;
  45. pb->description = "Logging library";
  46. return true;
  47. }
  48. //-------------------------------------------------------------------------------------------------------------------------------------------
  49. LOGGING_API void LOGGING_CALL logDbgLog(unsigned srcLen, const char * src)
  50. {
  51. DBGLOG("%.*s", srcLen, src);
  52. }