@@ -11,14 +11,16 @@ const puppeteer = require('puppeteer');
11
11
const os = require ( 'os' ) ;
12
12
const path = require ( 'path' ) ;
13
13
14
-
15
14
var url = process . argv [ 2 ] ;
16
15
var output = process . argv [ 3 ] ;
17
16
var width = process . argv [ 4 ] ;
18
17
var height = process . argv [ 5 ] ;
19
18
var sessionid = process . argv [ 6 ] ;
20
19
var is_report = process . argv [ 7 ] ;
21
20
var waitTimeout = 20000 ;
21
+ var debug = false ;
22
+
23
+ let _debug = debug ? console . log : function ( ) { } ;
22
24
23
25
// Set XDG_CONFIG_HOME and XDG_CACHE_HOME if not already set (chrome >= ~ 128 does not start otherwise)
24
26
var tempDir = "" ;
@@ -57,7 +59,7 @@ if (!process.env['XDG_CACHE_HOME']) { process.env['XDG_CACHE_HOME'] = tempDir;
57
59
await browser . close ( ) ;
58
60
process . exit ( 2 ) ;
59
61
}
60
- //console.debug ("response:", response.url(), response.status());
62
+ _debug ( "response:" , response . url ( ) , response . status ( ) ) ;
61
63
} )
62
64
63
65
// extract panelId parameter from url
@@ -72,7 +74,7 @@ if (!process.env['XDG_CACHE_HOME']) { process.env['XDG_CACHE_HOME'] = tempDir;
72
74
const response = await page . goto ( source_url ) ;
73
75
if ( ! response . ok ( ) ) {
74
76
console . log ( "fetching url " + source_url + " failed: " + response . status ( ) + " " + response . statusText ( ) )
75
- //console.log (response.text())
77
+ _debug ( response . text ( ) )
76
78
await browser . close ( ) ;
77
79
process . exit ( 2 ) ;
78
80
}
@@ -108,7 +110,7 @@ if (!process.env['XDG_CACHE_HOME']) { process.env['XDG_CACHE_HOME'] = tempDir;
108
110
const response = await page . goto ( api_url ) ;
109
111
if ( ! response . ok ( ) ) {
110
112
console . log ( "fetching url " + api_url + " failed: " + response . status ( ) + " " + response . statusText ( ) )
111
- //console.log (response.text())
113
+ _debug ( response . text ( ) )
112
114
await browser . close ( ) ;
113
115
process . exit ( 2 ) ;
114
116
}
@@ -133,7 +135,7 @@ if (!process.env['XDG_CACHE_HOME']) { process.env['XDG_CACHE_HOME'] = tempDir;
133
135
const response = await page . goto ( url ) ;
134
136
if ( ! response . ok ( ) ) {
135
137
console . log ( "fetching url " + url + " failed: " + response . status ( ) + " " + response . statusText ( ) )
136
- //console.log (response.text())
138
+ _debug ( response . text ( ) )
137
139
await browser . close ( ) ;
138
140
process . exit ( 2 ) ;
139
141
}
@@ -166,6 +168,7 @@ if (!process.env['XDG_CACHE_HOME']) { process.env['XDG_CACHE_HOME'] = tempDir;
166
168
} , async ( ) => {
167
169
if ( ! errorMsg ) {
168
170
errorMsg = "timeout while waiting for chart, export failed" ;
171
+ _debug ( errorMsg ) ;
169
172
//const pageSourceHTML = await page.content();
170
173
//console.log(pageSourceHTML);
171
174
}
@@ -184,7 +187,7 @@ if (!process.env['XDG_CACHE_HOME']) { process.env['XDG_CACHE_HOME'] = tempDir;
184
187
process . exit ( 0 ) ;
185
188
186
189
async function createScreenshot ( output , page ) {
187
- //console.debug ("creating screenshot");
190
+ _debug ( "creating screenshot" ) ;
188
191
if ( output . match ( / \. p d f $ / ) ) {
189
192
// pdf reports in din a4 format
190
193
if ( is_report == 1 ) {
0 commit comments