import_log.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import { import_process_fail } from "./import_process_fail";
  2. export class import_log {
  3. #log;
  4. constructor() {
  5. this.#log = new Array();
  6. }
  7. #append(target) {
  8. this.#log.push(target);
  9. }
  10. #error_dump(error) {
  11. return (
  12. "Error: "
  13. + new String(error) + "."
  14. );
  15. }
  16. #product_dump(product) {
  17. return (
  18. "Product: "
  19. + "barcode: \"" + product.barcode + "\", "
  20. + "title: \"" + product.title + "\"."
  21. );
  22. }
  23. fail(target) {
  24. this.#append(
  25. "Fail when processing item. "
  26. + this.#product_dump(target.product) + " "
  27. + this.#error_dump(target.error)
  28. );
  29. }
  30. skip(target) {
  31. this.#append(
  32. "Skipping not ready item. "
  33. + this.#product_dump(target.product) + " "
  34. + this.#error_dump(target.error)
  35. );
  36. }
  37. get length() {
  38. return this.#log.length;
  39. }
  40. content() {
  41. return this.#log.join("\n");
  42. }
  43. }