how to add a message prepend?
I almost always want a message when I log something out
ic('add_exit_items', len(agg_data))
but this comes out like:
'add_exit_items': 'add_exit_items'
len(agg_data): 300
is there a way to prepend an actual message (without changing the prexix for every message?) OR if i'm sending a string, just don't treat it like a dictionary?
I was thinking of wrapping the libary again to get what i want but then the context of where the logging is coming from would be broken...
using an array also doesn't help
ic(['length of stats', len(data)])
this lib looks so close? the debug() module for node is sorely needed in the python ecosystem
make sure to update icecream. youre running an old version
with the latest icecream, the prefix string message is just printed as-is. eg
from icecream import ic
e = 1000
ic('lolsup', e)
outputs
ic| 'lolsup', e: 1000
does this suffice for your needs?
that looks perfect... and yet:
maybe it works with single variables, but if i pass any kind of dict or dataframe it will still duplicate the message
ic('funnel', self.funnel)
=>
ChatFunnel |chat_funnel_spec.py:70 in load_funnel()
'funnel': 'funnel'
self.funnel: {'DIY_CompletePath_Grp': {8: 'GU3K'},
'call_flow': {8: 'Bill Explain'},
'cf_group': {8: 'Bill Explain'},
'cname': {8: 'Bill Due_date'},
'diy_name': {8: 'Bill Explain Cust Hangup'},
...
----
$ pip show icecream
Name: icecream
Version: 2.1.0
Summary: Never use print() to debug again; inspect variables, expressions, and program execution with a single, simple function call.
Home-page: https://github.com/gruns/icecream
a bug! i can reproduce
from icecream import ic
d = {'DIY_CompletePath_Grp': {8: 'GU3K'},
'call_flow': {8: 'Bill Explain'},
'cf_group': {8: 'Bill Explain'},
'cname': {8: 'Bill Due_date'},
'diy_name': {8: 'Bill Explain Cust Hangup'}}
ic('lolsup', d)
outputs
ic| 'lolsup': 'lolsup'
d: {'DIY_CompletePath_Grp': {8: 'GU3K'},
'call_flow': {8: 'Bill Explain'},
'cf_group': {8: 'Bill Explain'},
'cname': {8: 'Bill Due_date'},
'diy_name': {8: 'Bill Explain Cust Hangup'}}
this is a bug with multiline output (value printed twice) vs single line output (value only printed once)
ill fix this bug so both multiline output and single line output only print values (eg string literals) once, not twice
It would be nice to have this work also with f-strings:
d = {'a': 1}
ic(f'{d.keys()}', d)
# -> ic| f'{d.keys()}': "dict_keys(['a'])", d: {'a': 1}
I would like this to output ic| "dict_keys(['a'])", d: {'a': 1} instead.