mirror of
https://github.com/portainer/portainer.git
synced 2025-08-02 20:35:25 +02:00
fix(log-viewer): strip headers in container logs when TTY is disabled (#1861)
This commit is contained in:
parent
1e55ada6af
commit
e0cf088428
9 changed files with 81 additions and 26 deletions
|
@ -16,7 +16,7 @@ angular.module('portainer.docker')
|
|||
logs: {
|
||||
method: 'GET', params: { id: '@id', action: 'logs' },
|
||||
timeout: 4500, ignoreLoadingBar: true,
|
||||
transformResponse: logsHandler, isArray: true
|
||||
transformResponse: logsHandler
|
||||
},
|
||||
stats: {
|
||||
method: 'GET', params: { id: '@id', stream: false, action: 'stats' },
|
||||
|
|
|
@ -45,15 +45,11 @@ function genericHandler(data) {
|
|||
}
|
||||
|
||||
// The Docker API returns the logs as a single string.
|
||||
// This handler will return an array with each line being an entry.
|
||||
// It will also strip the 8 first characters of each line and remove any ANSI code related character sequences.
|
||||
// This handler wraps the data in a JSON object under the "logs" property.
|
||||
function logsHandler(data) {
|
||||
var logs = data;
|
||||
logs = logs.substring(8);
|
||||
logs = logs.replace(/\n(.{8})/g, '\n\r');
|
||||
logs = logs.replace(
|
||||
/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, '');
|
||||
return logs.split('\n');
|
||||
return {
|
||||
logs: data
|
||||
};
|
||||
}
|
||||
|
||||
// Image delete API returns an array on success (Docker 1.9 -> Docker 1.12).
|
||||
|
|
|
@ -17,7 +17,7 @@ angular.module('portainer.docker')
|
|||
logs: {
|
||||
method: 'GET', params: { id: '@id', action: 'logs' },
|
||||
timeout: 4500, ignoreLoadingBar: true,
|
||||
transformResponse: logsHandler, isArray: true
|
||||
transformResponse: logsHandler
|
||||
}
|
||||
});
|
||||
}]);
|
||||
|
|
|
@ -10,7 +10,7 @@ angular.module('portainer.docker')
|
|||
logs: {
|
||||
method: 'GET', params: { id: '@id', action: 'logs' },
|
||||
timeout: 4500, ignoreLoadingBar: true,
|
||||
transformResponse: logsHandler, isArray: true
|
||||
transformResponse: logsHandler
|
||||
}
|
||||
});
|
||||
}]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue