logging.cpp 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*##############################################################################
  2. Copyright (C) 2011 HPCC Systems.
  3. All rights reserved. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU Affero General Public License as
  5. published by the Free Software Foundation, either version 3 of the
  6. License, or (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU Affero General Public License for more details.
  11. You should have received a copy of the GNU Affero General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. ############################################################################## */
  14. #include <time.h>
  15. #include <stdlib.h>
  16. #include <string.h>
  17. #include <ctype.h>
  18. #include "logging.hpp"
  19. #include "jlog.hpp"
  20. #define LOGGING_VERSION "LOGGING 1.0.1"
  21. static const char * compatibleVersions[] = {
  22. "LOGGING 1.0.0 [66aec3fb4911ceda247c99d6a2a5944c]", // linux version
  23. LOGGING_VERSION,
  24. NULL };
  25. const char * EclDefinition =
  26. "export Logging := SERVICE\n"
  27. " dbglog(const string src) : c,action,entrypoint='logDbgLog'; \n"
  28. " addWorkunitInformation(const varstring txt, unsigned code=0, unsigned severity=0) : ctxmethod,action,entrypoint='addWuException'; \n"
  29. " addWorkunitWarning(const varstring txt, unsigned code=0, unsigned severity=1) : ctxmethod,action,entrypoint='addWuException'; \n"
  30. " addWorkunitError(const varstring txt, unsigned code=0, unsigned severity=2) : ctxmethod,action,entrypoint='addWuException'; \n"
  31. "END;";
  32. LOGGING_API bool getECLPluginDefinition(ECLPluginDefinitionBlock *pb)
  33. {
  34. if (pb->size == sizeof(ECLPluginDefinitionBlockEx))
  35. {
  36. ECLPluginDefinitionBlockEx * pbx = (ECLPluginDefinitionBlockEx *) pb;
  37. pbx->compatibleVersions = compatibleVersions;
  38. }
  39. else if (pb->size != sizeof(ECLPluginDefinitionBlock))
  40. return false;
  41. pb->magicVersion = PLUGIN_VERSION;
  42. pb->version = LOGGING_VERSION;
  43. pb->moduleName = "lib_logging";
  44. pb->ECL = EclDefinition;
  45. pb->flags = PLUGIN_IMPLICIT_MODULE;
  46. pb->description = "Logging library";
  47. return true;
  48. }
  49. //-------------------------------------------------------------------------------------------------------------------------------------------
  50. LOGGING_API void LOGGING_CALL logDbgLog(unsigned srcLen, const char * src)
  51. {
  52. DBGLOG("%.*s", srcLen, src);
  53. }