Logging
cartpole.log
Level
Classic log levels: UNKNOWN
, DEBUG
, INFO
, WARNING
, ERROR
, FATAL
Source code in cartpole/log.py
MCAPLogger
Logger to mcap file.
Example
Source code in cartpole/log.py
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 265 266 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 |
|
__init__(log_path: str, level: Level = Level.INFO, compress=True)
PARAMETER | DESCRIPTION |
---|---|
log_path |
path to mcap log file
TYPE:
|
level |
log level (
TYPE:
|
compress |
enable compression
DEFAULT:
|
Source code in cartpole/log.py
publish(topic_name: str, obj: BaseModel, stamp: float) -> None
Publish object to topic.
Parameters:
topic_name: topic name obj: Any object to dump (pydantic model) stamp: float timestamp in nanoseconds (float)
Source code in cartpole/log.py
log(msg: str, stamp: float, level: Level) -> None
Print message to topic /log
.
Parameters:
msg: str
message to print
stamp: float
timestamp in nanoseconds (float)
level: Level
log level (UNKNOWN
, DEBUG
, INFO
, WARNING
, ERROR
, FATAL
)
Source code in cartpole/log.py
debug(msg: str, stamp: float) -> None
info(msg: str, stamp: float) -> None
warning(msg: str, stamp: float) -> None
error(msg: str, stamp: float) -> None
fatal(msg: str, stamp: float) -> None
FoxgloveWebsocketLogger
Logger to foxglove websocket, messages are available in real time. Class will start new thread with asyncio event loop.
Example
Source code in cartpole/log.py
437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 |
|
__init__(level: int = Level.INFO)
PARAMETER | DESCRIPTION |
---|---|
level |
log level (
TYPE:
|
Source code in cartpole/log.py
publish(topic_name: str, obj: BaseModel, stamp: float) -> None
Publish object to topic.
PARAMETER | DESCRIPTION |
---|---|
topic_name |
topic name
TYPE:
|
obj |
object to dump (pydantic model)
TYPE:
|
stamp |
timestamp in nanoseconds (float)
TYPE:
|
Source code in cartpole/log.py
log(msg: str, stamp: float, level: int) -> None
Print message to topic /log
.
PARAMETER | DESCRIPTION |
---|---|
msg |
message to print
TYPE:
|
stamp |
timestamp in nanoseconds (float)
TYPE:
|
level |
log level (
TYPE:
|
Source code in cartpole/log.py
debug(msg: str, stamp: float) -> None
info(msg: str, stamp: float) -> None
warning(msg: str, stamp: float) -> None
error(msg: str, stamp: float) -> None
fatal(msg: str, stamp: float) -> None
Logger
Compound Logger class that logs to console, foxglove and mcap.
Example
Source code in cartpole/log.py
559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 |
|
__init__(log_path: str = '', level: Level = Level.INFO)
PARAMETER | DESCRIPTION |
---|---|
log_path |
path to mcap log file, if not provided, no mcap log will be created
TYPE:
|
level |
log level (
TYPE:
|
Source code in cartpole/log.py
publish(topic_name: str, obj: BaseModel, stamp: float) -> None
PARAMETER | DESCRIPTION |
---|---|
topic_name |
topic name
TYPE:
|
obj |
pydantic object
TYPE:
|
stamp |
timestamp in nanoseconds (float), if not provided, current time used
TYPE:
|
Source code in cartpole/log.py
log(msg: str, stamp: float, level: Level = Level.INFO) -> None
Print message to console and topic /log
.
PARAMETER | DESCRIPTION |
---|---|
msg |
message to print
TYPE:
|
stamp |
timestamp in nanoseconds (float), if not provided, current time used
TYPE:
|
level |
log level (
TYPE:
|
Source code in cartpole/log.py
debug(msg: str, stamp: float) -> None
info(msg: str, stamp: float) -> None
warning(msg: str, stamp: float) -> None
error(msg: str, stamp: float) -> None
fatal(msg: str, stamp: float) -> None
setup(log_path: str = '', level: Level = Level.INFO) -> None
Setup gloval logger.
PARAMETER | DESCRIPTION |
---|---|
log_path |
path to mcap log file, if not provided, no mcap log will be created
TYPE:
|
level |
log level (
TYPE:
|
Source code in cartpole/log.py
close()
get_logger() -> Logger
publish(topic_name: str, obj: BaseModel, stamp: float | None = None) -> None
Publish object to topic of global logger. If logger is not set, it will be created with default settings.
PARAMETER | DESCRIPTION |
---|---|
topic_name |
topic name
TYPE:
|
obj |
pydantic model
TYPE:
|
stamp |
timestamp in nanoseconds (float), if not provided, current time used
TYPE:
|
Source code in cartpole/log.py
log(msg: str, stamp: float | None = None, level: Level = Level.INFO) -> None
Print message to console and topic /log
.
If logger is not set, it will be created with default settings.
PARAMETER | DESCRIPTION |
---|---|
msg |
message to print
TYPE:
|
stamp |
timestamp in nanoseconds (float), if not provided, current time used
TYPE:
|
level |
log level (
TYPE:
|
Source code in cartpole/log.py
debug(msg: str, stamp: float | None = None) -> None
Print message to console and topic /log
with DEBUG
level.
If logger is not set, it will be created with default settings.
info(msg: str, stamp: float | None = None) -> None
Print message to console and topic /log
with INFO
level.
If logger is not set, it will be created with default settings.
warning(msg: str, stamp: float | None = None) -> None
Print message to console and topic /log
with WARNING
level.
If logger is not set, it will be created with default settings.
error(msg: str, stamp: float | None = None) -> None
Print message to console and topic /log
with ERROR
level.
If logger is not set, it will be created with default settings.
fatal(msg: str, stamp: float | None = None) -> None
Print message to console and topic /log
with FATAL
level.
If logger is not set, it will be created with default settings.