Forráskód Böngészése

:loud_sound: add logs

LI JIAHAO 6 éve
szülő
commit
1f1c699f33
2 módosított fájl, 8 hozzáadás és 0 törlés
  1. 4 0
      dist/webshot.js
  2. 4 0
      src/webshot.ts

+ 4 - 0
dist/webshot.js

@@ -18,6 +18,7 @@ function renderWebshot(url, height) {
             quality: 100,
             customCSS: 'html{zoom:2}header{display:none!important}',
         };
+        logger.info(`shooting ${options.windowSize.width}*${height} webshot for ${url}`);
         webshot(url, options).pipe(new pngjs_1.PNG({
             filterType: 4
         }))
@@ -32,13 +33,16 @@ function renderWebshot(url, height) {
                 }
             }
             if (boundary != null) {
+                logger.info(`found boundary at ${boundary}, cropping image`);
                 this.data = this.data.slice(0, (this.width * boundary) << 2);
                 this.height = boundary;
                 read(this.pack(), 'base64').then(data => {
+                    logger.info(`finished webshot for ${url}`);
                     resolve({ data, boundary });
                 });
             }
             else {
+                logger.warn(`unable to found boundary, try shooting a larger image`);
                 resolve({ data: '', boundary });
             }
         });

+ 4 - 0
src/webshot.ts

@@ -18,6 +18,7 @@ function renderWebshot(url: string, height: number): Promise<string> {
       quality: 100,
       customCSS: 'html{zoom:2}header{display:none!important}',
     };
+    logger.info(`shooting ${options.windowSize.width}*${height} webshot for ${url}`);
     webshot(url, options).pipe(new PNG({
       filterType: 4
     }))
@@ -32,12 +33,15 @@ function renderWebshot(url: string, height: number): Promise<string> {
           }
         }
         if (boundary != null) {
+          logger.info(`found boundary at ${boundary}, cropping image`);
           this.data = this.data.slice(0, (this.width * boundary) << 2);
           this.height = boundary;
           read(this.pack(), 'base64').then(data => {
+            logger.info(`finished webshot for ${url}`);
             resolve({ data, boundary });
           });
         } else {
+          logger.warn(`unable to found boundary, try shooting a larger image`);
           resolve({ data: '', boundary });
         }
       });