Comments (4)
Hey Tom, thanks for your interest! You're spot on. For intermediate results, I am generally adding to the Action data map. Otherwise, I create new Actions (nested actions are fine). Actions keep a reference to their parent, though this is contingent on your concurrency model, I have only really leveraged that for indentation.
Warnings have not been fully fleshed out, and I wouldn't recommend them for successful intermediate results anyways. A while back I looked at supporting multiple Action completions, but decided that a single completion had more useful semantics, especially since Actions can be nested.
Have you considered a single-line action? Something like:
log.debug('dbg_action', res='intermediate').success('{res} intermediate result')
Compared to the built-in logging expressions, it's a bit noisier, but it's also a lot more structured.
from lithoxyl.
Thanks for the extra details @mahmoud.
I agree, you don't want multiple completions, that doesn't really make sense.
Nesting using a single-line action produces clean enough code that I'd be happy with, but I'm using a variant of the SyslogEmitter
that only outputs the end_event, so the log entry for the intermediate result looks a bit odd, e.g. before I had output roughly like:
INFO starting some process
DEBUG intermediate result a
DEBUG another intermediate result b
INFO complete
And now I get:
DEBUG "intermediate result a"
DEBUG "another intermediate result b"
INFO "process succeeded"
It would be very instructive to see how you'd refactor some real-world code that has fairly extensive usage of logging.getLogger
using lithoxyl.
from lithoxyl.
Sure! So, for sure this is one of the most immediate friction points one would hit, especially coming from logging
. I've yet to have project that didn't have some long-running task that I wanted some confirmation of having started. Lithoxyl has begin
events, the question is when to emit them. There's not really a way where a parent can know it will have a nested event, or that it will be a long-running task, so we have to compromise and be able to mark these ourself.
There are two approaches I use:
- Emit
begin
events for transactions marked asverbose
. - Emit
begin
events for transactions with above a certain level (e.g., >debug in your case)
You can see the first approach in action in Chert. Note the separate complete format (fmt
) and begin format (begin_fmt
). This gives an output like:
b+0.277090 -------------- "render site beginning"
F+0.277154 - 0.008ms - "no pre_render hook defined"
b+0.278630 -------------- "render published entry content beginning"
S+1.213840 - 935.210ms - "render published entry content succeeded - ({'verbose': True})"
b+1.214119 -------------- "render draft entry content beginning"
S+2.776296 - 1562.177ms - "render draft entry content succeeded - ({'verbose': True})"
b+2.776552 -------------- "render special entry content beginning"
S+2.787829 - 11.277ms - "render special entry content succeeded - ({'verbose': True})"
S+2.826007 - 37.902ms - "render entry html succeeded"
S+2.891567 - 65.425ms - "render feed and tag lists succeeded"
S+2.892354 - 2615.264ms - "render site succeeded - ({'verbose': True})"
I'm not super happy about the ({'verbose': True})
, but it works pretty well thus far. Enough so that I've made verbose a special part of SensibleFilter
.
How's that sounding?
from lithoxyl.
Yes, that's pretty good, thanks. Real-world example code is always helpful.
Agreed re verbose
, maybe there's a way to filter that out of SensibleFormatter
/SensibleMessageFormatter
?
It seems to me there's room for lithoxyl to get a bit more opinionated about the "sensible" setup too - e.g. with a couple of pre-built sinks for stderr, syslog etc. that can be added to a Logger with a line or two of code to reduce the friction when getting started. I had a question on StackOverflow about creating an emitter that outputs to the logging module, similar to the SyslogEmitter, that may fit into that pre-rolled sink category too.
from lithoxyl.
Related Issues (7)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lithoxyl.