Skip to content
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

New SlackWebookHandler and long context/extras problem #909

Closed
mirfilip opened this issue Jan 5, 2017 · 6 comments
Closed

New SlackWebookHandler and long context/extras problem #909

mirfilip opened this issue Jan 5, 2017 · 6 comments
Labels

Comments

@mirfilip
Copy link

mirfilip commented Jan 5, 2017

Hi,
I just got around to test the new cool SlackWebhookHandler. It works nice and fixes problems I had before, there is however one annoyance I found. @an1zhegorodov I didn't want to continue discussion in your original PR though.

I use attachments and include context and extra data. Depending on the length of the context, it's either formatted well or cut:

Looking good:

$nestedArray = [];
for ($i = 0; $i < 27; $i++) {
    $nestedArray["foo $i"] = str_repeat($i, $i * 2);
}
$context = ['nested' => $nestedArray];
$this->logger->warning('Warning test', $context);

the whole nested array is displayed in code block (using "```").

If I, however, make it bigger:

$nestedArray = [];
for ($i = 0; $i < 30; $i++) {
    $nestedArray["foo $i"] = str_repeat($i, $i * 2);
}
$context = ['nested' => $nestedArray];
$this->logger->warning('Warning test', $context);

The context output is truncated and the whole code block is broken. Below, it's how it looks like at the beginning of the msg (I don't include full msg cause it's big):
slack_monolog_handler_big_context

You can see at the beginning that there is no closing "```" of code block (probably because truncation). I don't have time to debug this now, it could be as well a limitation of Slack Webhook formatting.

What I'm trying to do:
I want to include a stacktrace (not based on exception) in a context so that it's prettified and displayed in code block on Slack. The NormalizerFormatter and "stringification" get the job done, but only for small contexts.

@mintobit
Copy link
Contributor

mintobit commented Jan 7, 2017

After debugging this, I can tell there is limitation somewhere around 2000 symbols for each attachment imposed by slack itself. Any ideas how to handle this?

@acasademont
Copy link
Contributor

AFAIK there are no limits when using the normal message field instead of attachments, which is the weirdest thing ever...

@Seldaek
Copy link
Owner

Seldaek commented Mar 12, 2017

Maybe you could truncate the output by hand to make sure the backticks is present at the end, or at least report it to slack so that they fix their truncation to not rip apart a code block..

@mirfilip
Copy link
Author

@Seldaek I hope by you, you mean me - the user of the library. Then - yes, I could, I already do that since I found out about the limitation.

I didn't have time to look into it but I'll get around to reporting it someday ;)

@Seldaek
Copy link
Owner

Seldaek commented Mar 13, 2017

@mirfilip By you I mean anyone running into this issue that feels like fixing it in monolog, or in slack :)

@gmponos
Copy link
Contributor

gmponos commented Nov 29, 2018

Because I had to deal with the same issue I have created this package. You can find it also in wiki of monolog.

@Seldaek Seldaek closed this as completed Dec 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants