Skip to content

Commit c9bbc13

Browse files
authored
fix: console logs transport (#3655)
2 parents 4f27ffc + 84f748d commit c9bbc13

File tree

3 files changed

+1
-62
lines changed

3 files changed

+1
-62
lines changed

packages/artillery/lib/console-capture.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
const debug = require('debug')('console-capture');
2-
const _sleep = require('./util/sleep');
32

43
function setupConsoleCapture() {
54
let outputLines = [];

packages/artillery/lib/platform/aws-ecs/legacy/run-cluster.js

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -157,66 +157,6 @@ function logProgress(msg, opts = {}) {
157157
}
158158

159159
async function tryRunCluster(scriptPath, options, artilleryReporter) {
160-
const MAX_RETAINED_LOG_SIZE_MB = Number(
161-
process.env.MAX_RETAINED_LOG_SIZE_MB || '50'
162-
);
163-
const MAX_RETAINED_LOG_SIZE = MAX_RETAINED_LOG_SIZE_MB * 1024 * 1024;
164-
165-
let currentSize = 0;
166-
// Override console.log so as not to interfere with the spinner
167-
let outputLines = [];
168-
let truncated = false;
169-
170-
console.log = (() => {
171-
const orig = console.log;
172-
return (...args) => {
173-
try {
174-
orig.apply(console, args);
175-
176-
if (currentSize < MAX_RETAINED_LOG_SIZE) {
177-
outputLines = outputLines.concat(args);
178-
for (const x of args) {
179-
currentSize += String(x).length;
180-
}
181-
} else {
182-
if (!truncated) {
183-
truncated = true;
184-
const msg = `[WARNING] Artillery: maximum retained log size exceeded, max size: ${MAX_RETAINED_LOG_SIZE_MB}MB. Further logs won't be retained.\n\n`;
185-
process.stdout.write(msg);
186-
outputLines = outputLines.concat([msg]);
187-
}
188-
}
189-
} catch (err) {
190-
debug(err);
191-
}
192-
};
193-
})();
194-
195-
console.error = (() => {
196-
const orig = console.error;
197-
return (...args) => {
198-
try {
199-
orig.apply(console, args);
200-
201-
if (currentSize < MAX_RETAINED_LOG_SIZE) {
202-
outputLines = outputLines.concat(args);
203-
for (const x of args) {
204-
currentSize += String(x).length;
205-
}
206-
} else {
207-
if (!truncated) {
208-
truncated = true;
209-
const msg = `[WARNING] Artillery: maximum retained log size exceeded, max size: ${MAX_RETAINED_LOG_SIZE_MB}MB. Further logs won't be retained.\n\n`;
210-
process.stdout.write(msg);
211-
outputLines = outputLines.concat([msg]);
212-
}
213-
}
214-
} catch (err) {
215-
debug(err);
216-
}
217-
};
218-
})();
219-
220160
global.artillery.awsRegion = (await awsGetDefaultRegion()) || options.region;
221161

222162
let context = {};

packages/artillery/lib/platform/cloud/cloud.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ class ArtilleryCloudPlugin {
135135
console.log(stringifyErr);
136136
}
137137
for (const args of lines) {
138-
text += `${util.format(...Object.keys(args).map((k) => args[k]))}\n`;
138+
text += util.format(...Object.keys(args).map((k) => args[k])) + '\n';
139139
}
140140

141141
try {

0 commit comments

Comments
 (0)