Logging in view.py is a bit more complicated than other libraries. The original logging
module that comes with Python wasn't really fun to deal with, so a more abstracted API on top of it was designed.
_Logger
is an abstract class to give a nicer, more object oriented approach to logging. To create a new _Logger
ready class, simply inherit from it and specify a logging.Logger object
:
class MyLogger(_Logger):
log = logging.getLogger("MyLogger")
MyLogger
above could then be used like so:
MyLogger.info("something")
_Logger
Bases: ABC
Wrapper around the built in logger.
src/view/_logging.py
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 |
|
critical(*msg, **kwargs)
classmethod
Write critical message.
src/view/_logging.py
282 283 284 285 |
|
debug(*msg, **kwargs)
classmethod
Write debug message.
src/view/_logging.py
262 263 264 265 |
|
error(*msg, **kwargs)
classmethod
Write error message.
src/view/_logging.py
277 278 279 280 |
|
exception(*msg, **kwargs)
classmethod
Write exception.
src/view/_logging.py
287 288 289 290 |
|
info(*msg, **kwargs)
classmethod
Write info message.
src/view/_logging.py
267 268 269 270 |
|
warning(*msg, **kwargs)
classmethod
Write warning message.
src/view/_logging.py
272 273 274 275 |
|
view.py has two loggers, Service
and Internal
. Service
is meant for general app information that is sent to the user, whereas Internal
is meant for debugging.
Bases: _Logger
Logger to be seen by the user when the app is running.
src/view/_logging.py
293 294 295 296 |
|
Bases: _Logger
Logger to be seen by view.py developers for debugging purposes.
src/view/_logging.py
299 300 301 302 |
|
Warnings have been customized for view.py to give a prettier output for the user. The implementation is taken from this issue.
Fancy mode is a special output for running an app. It's powered by rich live and has some specially designed components. It wraps things like I/O counts to a graph for more eye candy at runtime. It can be started via enter_server
and ended via exit_server
.
Once online, special QueueItem
objects are sent to _QUEUE
, which is handled by the live display and updated on screen.
Dataset
Dataset in a graph.
src/view/_logging.py
711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 |
|
__init__(name, point_limit=None)
Args: name: Name of the dataset. point_limit: Amount of points allowed in the dataset at a time.
src/view/_logging.py
714 715 716 717 718 719 720 721 |
|
add_point(x, y)
Add a point to the dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x |
float
|
X value. |
required |
y |
float
|
Y value. |
required |
src/view/_logging.py
723 724 725 726 727 728 729 730 731 732 733 734 735 |
|
add_points(*args)
Add multiple points to the dataset.
src/view/_logging.py
737 738 739 740 |
|
HeatedProgress
Bases: Progress
Progress that changes color based on how close the bar is to completion.
src/view/_logging.py
819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 |
|
Internal
Bases: _Logger
Logger to be seen by view.py developers for debugging purposes.
src/view/_logging.py
299 300 301 302 |
|
LogPanel
Bases: Panel
Panel with limit on number of lines relative to the terminal size.
src/view/_logging.py
650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 |
|
write(text)
Write text to the panel.
src/view/_logging.py
662 663 664 665 666 667 668 |
|
LogTable
Bases: Table
Table with limit on number of columns relative to the terminal height.
src/view/_logging.py
695 696 697 698 699 700 701 702 703 704 705 706 707 708 |
|
Plot
Plot renderable for rich.
src/view/_logging.py
743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 |
|
__init__(name, x, y)
Args: name: Title of the graph. x: X label of the graph. y: Y label of the graph.
src/view/_logging.py
746 747 748 749 750 751 752 753 754 755 756 757 |
|
dataset(name, *, point_limit=None)
Generate or create a new dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
Name of the dataset. |
required |
point_limit |
int | None
|
Limit on the number of points to be allowed on the graph at a time. If not set, terminal size divided by 3 is used. |
None
|
src/view/_logging.py
759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 |
|
Service
Bases: _Logger
Logger to be seen by the user when the app is running.
src/view/_logging.py
293 294 295 296 |
|
enter_server()
Start fancy mode.
src/view/_logging.py
989 990 991 992 993 994 |
|
exit_server()
End fancy mode.
src/view/_logging.py
997 998 999 |
|