You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -109,11 +109,12 @@ Using a logger [<a href="https://github.com/andy-landy/traceback_with_variables/
109
109
110
110
<ahref="https://github.com/andy-landy/traceback_with_variables/tree/master/examples/format_customized.py">Customize</a> any of the previous examples:
111
111
```python
112
+
from traceback_with_variables import fmt
112
113
fmt.max_value_str_len =10000
113
114
fmt.skip_files_except ='my_project'
115
+
fmt.custom_var_printers = [] # show all variables, no skips, no hides
@@ -247,8 +248,8 @@ Using a logger [<a href="https://github.com/andy-landy/traceback_with_variables/
247
248
248
249
* — Should I use it after debugging is over, i.e. *in production*?
249
250
250
-
Yes, of course! That way it might save you even more time (watch out for sensitive data
251
-
like passwords and tokens in you logs, use skip_files_except to hide code from libs AND custom_var_printers to hide own locals). Note: you can deploy more serious frameworks, e.g. `Sentry`
251
+
Yes, of course! That way it might save you even more time (<a href="https://github.com/andy-landy/traceback_with_variables/tree/master/examples/secret_data.py">watch out</a> for sensitive data
252
+
like 🔴**passwords** and **tokens** in you logs). Note: you can deploy more serious monitoring frameworks, e.g. `Sentry`
252
253
253
254
<br/>
254
255
@@ -261,7 +262,16 @@ Using a logger [<a href="https://github.com/andy-landy/traceback_with_variables/
261
262
step 5: Examine the printouts and possibly add some more info (then go back to step 2). \
262
263
step 6: Erase all recently added printouts, logging and exception messages. \
263
264
step 7: Go back to step 1 once bugs appear.
264
-
265
+
266
+
267
+
* — Is it slow? I have huge lists and dicts and data objects!
268
+
269
+
Data size doesn't matter! Printing is smart, so only the resulting suffix and prefix are generated, e.g.
270
+
271
+
`list(range(100000000))` becomes just `"[0, 1, 2, ...9998, 99999999]"` in 0.00012s
272
+
273
+
Use `fmt`'s `.max_value_str_len`, and `.ellipsis_rel_pos` (0.0 to 1.0) to tweak the output.
274
+
265
275
266
276
### Examples and recipes
267
277
@@ -279,6 +289,7 @@ Using a logger [<a href="https://github.com/andy-landy/traceback_with_variables/
279
289
* <a href="https://github.com/andy-landy/traceback_with_variables/tree/master/examples/work_with_traceback_lines.py">get traceback lines for custom things</a>
280
290
* <a href="https://github.com/andy-landy/traceback_with_variables/tree/master/examples/flask.py">using with `flask`</a>
281
291
* <a href="https://github.com/andy-landy/traceback_with_variables/tree/master/examples/format_customized.py">customize the output</a>
292
+
* <a href="https://github.com/andy-landy/traceback_with_variables/tree/master/examples/secret_data.py">passwords and tokens in logs</a>
282
293
283
294
### Reference
284
295
@@ -292,7 +303,7 @@ Using a logger [<a href="https://github.com/andy-landy/traceback_with_variables/
292
303
* `ellipsis_` string to denote long strings truncation, default=`...`
293
304
* `skip_files_except` use to print only certain files; list of regexes, ignored if empty, default=None
294
305
* `brief_files_except` use to print variables only in certain files; list of regexes, ignored if empty, default=None
295
-
* `custom_var_printers` list of pairs of (filter, printer); filter is a name fragment, a type or a function or a list thereof; printer returns `None` to skip a var
306
+
* `custom_var_printers` list of pairs of (filter, printer); filter is a name fragment, a type or a function or a list thereof; printer returns `None` to skip a var, standard ones are `hide`, `skip`, `show`
296
307
* `color_scheme` is `None` or one of <a href="https://github.com/andy-landy/traceback_with_variables/tree/master/traceback_with_variables/color.py">`ColorSchemes`</a>: `.none` , `.common`, `.nice`, `.synthwave`. `None` is for auto-detect
@@ -109,11 +109,12 @@ Using a logger [<a href="{{ examples_code_url }}/log_for_function.py">with a dec
109
109
110
110
<a href="{{ examples_code_url }}/format_customized.py">Customize</a> any of the previous examples:
111
111
```python
112
+
from traceback_with_variables import fmt
112
113
fmt.max_value_str_len = 10000
113
114
fmt.skip_files_except = 'my_project'
115
+
fmt.custom_var_printers = [] # show all variables, no skips, no hides
114
116
```
115
117
116
-
117
118
### Colors
118
119
119
120

@@ -247,8 +248,8 @@ Using a logger [<a href="{{ examples_code_url }}/log_for_function.py">with a dec
247
248
248
249
* — Should I use it after debugging is over, i.e. *in production*?
249
250
250
-
Yes, of course! That way it might save you even more time (watch out for sensitive data
251
-
like passwords and tokens in you logs, use skip_files_except to hide code from libs AND custom_var_printers to hide own locals). Note: you can deploy more serious frameworks, e.g. `Sentry`
251
+
Yes, of course! That way it might save you even more time (<a href="{{ examples_code_url }}/secret_data.py">watch out</a> for sensitive data
252
+
like 🔴**passwords** and **tokens** in you logs). Note: you can deploy more serious monitoring frameworks, e.g. `Sentry`
252
253
253
254
<br/>
254
255
@@ -261,7 +262,16 @@ Using a logger [<a href="{{ examples_code_url }}/log_for_function.py">with a dec
261
262
step 5: Examine the printouts and possibly add some more info (then go back to step 2). \
262
263
step 6: Erase all recently added printouts, logging and exception messages. \
263
264
step 7: Go back to step 1 once bugs appear.
264
-
265
+
266
+
267
+
* — Is it slow? I have huge lists and dicts and data objects!
268
+
269
+
Data size doesn't matter! Printing is smart, so only the resulting suffix and prefix are generated, e.g.
270
+
271
+
`list(range(100000000))` becomes just `"[0, 1, 2, ...9998, 99999999]"` in 0.00012s
272
+
273
+
Use `fmt`'s `.max_value_str_len`, and `.ellipsis_rel_pos` (0.0 to 1.0) to tweak the output.
274
+
265
275
266
276
### Examples and recipes
267
277
@@ -279,6 +289,7 @@ Using a logger [<a href="{{ examples_code_url }}/log_for_function.py">with a dec
279
289
* <a href="{{ examples_code_url }}/work_with_traceback_lines.py">get traceback lines for custom things</a>
280
290
* <a href="{{ examples_code_url }}/flask.py">using with `flask`</a>
281
291
* <a href="{{ examples_code_url }}/format_customized.py">customize the output</a>
292
+
* <a href="{{ examples_code_url }}/secret_data.py">passwords and tokens in logs</a>
282
293
283
294
### Reference
284
295
@@ -292,7 +303,7 @@ Using a logger [<a href="{{ examples_code_url }}/log_for_function.py">with a dec
292
303
* `ellipsis_` string to denote long strings truncation, default=`...`
293
304
* `skip_files_except` use to print only certain files; list of regexes, ignored if empty, default=None
294
305
* `brief_files_except` use to print variables only in certain files; list of regexes, ignored if empty, default=None
295
-
* `custom_var_printers` list of pairs of (filter, printer); filter is a name fragment, a type or a function or a list thereof; printer returns `None` to skip a var
306
+
* `custom_var_printers` list of pairs of (filter, printer); filter is a name fragment, a type or a function or a list thereof; printer returns `None` to skip a var, standard ones are `hide`, `skip`, `show`
296
307
* `color_scheme` is `None` or one of <a href="{{ lib_code_url }}/color.py">`ColorSchemes`</a>: `.none` , `.common`, `.nice`, `.synthwave`. `None` is for auto-detect
0 commit comments