3 ms·
Does anyone ever log in multi dimensional way at all? Everyone seems to just go, logger.info('Doing that') But logs really should be covering the context i
by mekster 4y ago
Does anyone ever log in multi dimensional way at all?
Everyone seems to just go,
logger.info('Doing that')
But logs really should be covering the context instead of being single dimensional by being placed at the execution point, which will also make the code far more readable.
//Sorry, I don't know python well but trying to run a lambda as a parameter.
myLogger.info('Doing that', lambda : (
doThat()
whatNot()))
And then, you know exactly what the log is covering as well as take a benchmark of the said part and report how long it took to run.
You don't need 'Done that' logging, as if you throw inside, the log doesn't happen.
You might want to know 'Doing that' was run even if it threw inside, but if logging is paired with an error reporting tools like Sentry, which is quite essential than depending on simple logging, you can know the stack trace easily to track which part of the code was run.
It seems no logging libraries do it the multidimensional way but it's an essential part of how I do logging.