-
Notifications
You must be signed in to change notification settings - Fork 305
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dogwrap: Trim output #91
Comments
Thanks a lot for the detailed explanations @gnarf ! I like the idea of making the 'trim' strategy configurable. I reckon 'head' should probably be the default behavior. We'll work on it for the next version 🚀 |
Considering the errors are USUALLY at the bottom when there are errors, I On Mon, Oct 19, 2015 at 6:55 PM, Yann notifications@github.com wrote:
|
You make a point, the third option sounds more reasonable. |
This code is like really quick and dirty, but this is what I implemented in my own node.js script (if it helps at all) Note: module.exports = function(err, event) {
var text = "%%%\nExit Code: " + event.exit + " Time: " + (event.time/1000).toFixed(3) + "s\n";
var payload_text_limit = 4000;
if (event.output.length > (payload_text_limit - text.length - 100) ) {
text += 'Start:\n```\n';
var lines = event.output.split('\n');
while (text.length < (payload_text_limit / 3)) {
text += lines.shift() + '\n';
}
text += '```\n';
text += '...trimmed...\n';
text += '```\n';
var ending = '```\n';
while ((ending.length + text.length + lines[lines.length-1].length + 1) < payload_text_limit) {
ending = lines.pop() + '\n' + ending;
}
text += ending;
} else {
text += 'Output:\n```\n' + event.output + '\n```\n';
}
var properties = {
tags: [ '#deploy:' + event.eventData.owner + '/' + event.eventData.repo, '#env:{{ deploy_env }}' ],
host: os.hostname(),
alert_type: event.exit ? 'error' : 'success',
date_happened: event.start,
source_type_name: 'deploy',
};
dogapi.event.create("[" + os.hostname() + "] deploy " + event.filename, text, properties);
}; I'm not proud of the readability or methods this thing uses, but hey - it works ;) |
**Changes** * New event body format: ``` >>>> CMD <<<< >>>> EXIT CODE <<<< >>>> STDOUT <<<< >>>> STDERR <<<< >>>> NOTIFICATIONS <<<< ``` * Trim output to not exceed `MAX_EVENT_BODY_LENGTH` size * Keep the first 1/3rd of the budget on the top, and the other 2 thirds on the bottom. Fix #91 Thanks @gnarf !
**Changes** * New event body format: ``` >>>> CMD <<<< >>>> EXIT CODE <<<< >>>> STDOUT <<<< >>>> STDERR <<<< >>>> NOTIFICATIONS <<<< ``` * Trim output to not exceed `MAX_EVENT_BODY_LENGTH` size * Keep the first 1/3rd of the budget on the top, and the other 2 thirds on the bottom. Fix #91 Thanks @gnarf !
When a command has output that makes the message exceed the 4000 character limit for events, the formating gets completely lost and so does the notifications that are appended ( #88 )
There should probably be a strategy in place to trim the output to something that fits in an event. I'd suggest it be configurable.
Total size of the event can not be > 4000 characters, so a few different strategies make sense to me
...trimmed...
in the middle, the first 1/3rd of the budget on the top, and the other 2 thirds on the bottom.The text was updated successfully, but these errors were encountered: