Add additional data (description/context) to error logging

Issue #6 new
Ethan Stern created an issue

As I’m refactoring out my old logger, I’m left wanting for one of its behaviors. Could we have an additional input (I think a string would be fine in all of my cases) for additional description or context? This is a place I normally include additional info that must come from the context that produced the error. Sometimes I include debugging tips like “check the com port assignment for this device” if the code knows a likely reason for the error. To get this functionality with the new logger, I need to call sequential logs (one for the error and another for the suggested remediation/additional context) and put the ‘plain’ event log call into an error case selector to make sure I only suggest the remedy when the error occurs.

If modifying the existing “Log If Error” isn’t feasible, how about adding an additional method like “Log If Error With Context”?

Comments (5)

  1. paul.ross@composed.io

    How would you want the new string and the error message to be put together? Just concatenate the context on at the end of the error string? I don’t see any reason this couldn’t be implemented, although I might want to rework the connector pane of that method to make it a bit cleaner

  2. paul.ross@composed.io

    This is the code that currently gets called when using the log if error method. I added the error format class as a way to preserve the ability to use the error class system Jon’s old logger had. I could certainly just append the context string to the end, and if someone wanted something different they could use a specific error formatter

  3. Ethan Stern reporter

    Basically, yes, with the exception (but not requirement) that I put the context before the error text, because it is usually the most relevant/important/human-readable information when trying to fix the problem. When error descriptions grow long, it’s easy to be overwhelmed by the string and--not that I’d ever do this--NOT read the whole thing through to the end. (okay, I do that all the time.)

  4. Log in to comment