ezpz.log
ΒΆ
Logging utilities built on top of Rich.
ezpz/log/init.py
Console
ΒΆ
Bases: Console
Extends rich Console class.
Source code in src/ezpz/log/console.py
__init__(*args, redirect=True, **kwargs)
ΒΆ
enrich console does soft-wrapping by default and this diverge from original rich console which does not, creating hard-wraps instead.
Source code in src/ezpz/log/console.py
print(*args, **kwargs)
ΒΆ
Print override that respects user soft_wrap preference.
Source code in src/ezpz/log/console.py
FluidLogRender
ΒΆ
Renders log by not using columns and avoiding any wrapping.
Source code in src/ezpz/log/handler.py
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 |
|
RichHandler
ΒΆ
Bases: RichHandler
Enriched handler that does not wrap.
Source code in src/ezpz/log/handler.py
render(*, record, traceback, message_renderable)
ΒΆ
Render log for display.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
record
|
LogRecord
|
logging Record. |
required |
traceback
|
Optional[Traceback]
|
Traceback instance or None for no Traceback. |
required |
message_renderable
|
ConsoleRenderable
|
Renderable (typically Text) containing log message contents. |
required |
Returns:
Name | Type | Description |
---|---|---|
ConsoleRenderable |
ConsoleRenderable
|
Renderable to display log. |
Source code in src/ezpz/log/handler.py
get_active_enrich_handlers(logger)
ΒΆ
Return (index, handler)
pairs for active RichHandler
instances.
Source code in src/ezpz/log/__init__.py
get_console_from_logger(logger)
ΒΆ
Return the Console
attached to logger or synthesise a new one.
Source code in src/ezpz/log/__init__.py
get_enrich_logging_config_as_yaml(name='enrich', level='INFO')
ΒΆ
Render the Enrich logging YAML snippet with the requested name/level.
Source code in src/ezpz/log/__init__.py
get_file_logger(name=None, level='INFO', rank_zero_only=True, fname=None)
ΒΆ
Create a file-backed logger, optionally emitting only on rank zero.
Source code in src/ezpz/log/__init__.py
get_logger(name=None, level=None, rank_zero_only=True, rank=None, colored_logs=True)
ΒΆ
Return a logger initialised with the project's logging configuration.
Source code in src/ezpz/log/__init__.py
get_logger1(name=None, level='INFO', rank_zero_only=True, **kwargs)
ΒΆ
Legacy helper retained for compatibility; prefer :func:get_logger
.
Source code in src/ezpz/log/__init__.py
get_logger_new(name, level='INFO')
ΒΆ
Return a logger configured solely via the Enrich YAML template.
Source code in src/ezpz/log/__init__.py
get_rich_logger(name=None, level=None)
ΒΆ
Return a logger backed by a single :class:RichHandler
.
Source code in src/ezpz/log/__init__.py
make_layout(ratio=4, visible=True)
ΒΆ
Define the layout.
Source code in src/ezpz/log/style.py
print_config(config, resolve=True)
ΒΆ
Prints content of DictConfig using Rich library and its tree structure.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config
|
DictConfig
|
Configuration composed by Hydra. |
required |
print_order
|
Sequence[str]
|
Determines in what order config components are printed. |
required |
resolve
|
bool
|
Whether to resolve reference fields of DictConfig. |
True
|
Source code in src/ezpz/log/style.py
print_styles()
ΒΆ
Print the configured logging styles (optionally exporting to HTML).
Source code in src/ezpz/log/__init__.py
print_styles_alt(html=False, txt=False)
ΒΆ
Variant of :func:print_styles
with HTML and plain-text exports.
Source code in src/ezpz/log/__init__.py
printarr(*arrs, float_width=6)
ΒΆ
Print a pretty table giving name, shape, dtype, type, and content information for input tensors or scalars.
Call like: printarr(my_arr, some_other_arr, maybe_a_scalar). Accepts a variable number of arguments.
Inputs can be
- Numpy tensor arrays
- Pytorch tensor arrays
- Jax tensor arrays
- Python ints / floats
- None
It may also work with other array-like types, but they have not been tested
Use the float_width
option specify the precision to which floating point
types are printed.
Author: Nicholas Sharp (nmwsharp.com) Canonical source: https://gist.github.com/nmwsharp/54d04af87872a4988809f128e1a1d233 License: This snippet may be used under an MIT license, and it is also released into the public domain. Please retain this docstring as a reference.
Source code in src/ezpz/log/style.py
267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 |
|
should_do_markup(stream=sys.stdout)
ΒΆ
Decide about use of ANSI colors.
Source code in src/ezpz/log/console.py
to_bool(value)
ΒΆ
Return a bool for the arg.