LoggerSerializers.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import Path from 'node:path'
  2. const CLSI_REQUEST_SERIALIZED_PROPERTIES = [
  3. 'compiler',
  4. 'compileFromClsiCache',
  5. 'populateClsiCache',
  6. 'enablePdfCaching',
  7. 'pdfCachingMinChunkSize',
  8. 'timeout',
  9. 'imageName',
  10. 'draft',
  11. 'stopOnFirstError',
  12. 'check',
  13. 'flags',
  14. 'compileGroup',
  15. 'syncType',
  16. ]
  17. export default {
  18. /**
  19. * Serializer for a CLSI request object.
  20. * Only includes properties useful for logging.
  21. * Excludes large, sensitive, or irrelevant properties (e.g., 'syncState', 'resources').
  22. * To add more properties, update the allowed properties above.
  23. *
  24. * @param {object} clsiRequest - The original CLSI request object.
  25. * @returns {object} A summarized version of the request object for logging.
  26. */
  27. clsiRequest(clsiRequest) {
  28. const summary = {}
  29. for (const key of CLSI_REQUEST_SERIALIZED_PROPERTIES) {
  30. if (key === 'imageName' && clsiRequest.imageName) {
  31. summary.imageName = Path.basename(clsiRequest.imageName)
  32. } else if (clsiRequest[key] !== undefined) {
  33. summary[key] = clsiRequest[key]
  34. }
  35. }
  36. return summary
  37. },
  38. }