https://dagster.io/ logo
#announcements
Title
# announcements
j

Josh Karlin

02/05/2021, 5:31 PM
hi again, does the dagster logger allow lazy logging? it doesn't like having extra args for string formatting in the way the normal python logger does e.g.
<http://log.info|log.info>("the next train is at %s", never)
m

max

02/05/2021, 5:41 PM
it doesn't at the moment
this would be a reasonable feature request but might require us to rethink the way that logging works; right now log level is really just a filter that dagit, etc., uses to decide which messages to display
👍 1
all of the messages are generated and stored though
mm, i could be wrong, actually, it might be easy to implement
n

Noah K

02/05/2021, 5:54 PM
That isn't a thing in Python anymore
<http://log.info|log.info>(f"the next train is at {never}")
j

Josh Karlin

02/05/2021, 6:03 PM
f strings aren't lazily evaluated though and errors in the string formatting are handled differently. a colleague has also had issues with log aggregation when log statements have f-strings though i have no experience with that https://medium.com/swlh/why-it-matters-how-you-log-in-python-1a1085851205
n

Noah K

02/05/2021, 6:03 PM
Not sure what you mean by lazy evaluation then
j

Josh Karlin

02/05/2021, 6:07 PM
sorry, i have an appointment with some wine so I will come back to this on monday!
e

esztermarton

02/05/2021, 6:15 PM
hah @Noah K in this case lazy evaluation just refers to the fact that IF relying on the inbuilt logging module - like @Josh Karlin posted in the original post - string formatting only happens if the logging level is hit - i.e. if you have very many DEBUG logs but your log level is INFO or WARNING etc, the DEBUG logs' strings won't get formatted. However if you format the string yourself, e.g. by using an f-string or
"something %s this" % "like"
then formatting happens when the execution goes over that line of code, whether or not it actually logs
n

Noah K

02/05/2021, 6:18 PM
You mean re: delaying the call to str?
That's lazy of a form
But not usually saving a lot of time 🙂
And that couldn't really work with dagit since the level selector happens so much later, off in javascript
3 Views