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
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 |
|
critical(*msg, **kwargs)
classmethod
Write critical message.
src/view/_logging.py
290 291 292 293 |
|
debug(*msg, **kwargs)
classmethod
Write debug message.
src/view/_logging.py
270 271 272 273 |
|
error(*msg, **kwargs)
classmethod
Write error message.
src/view/_logging.py
285 286 287 288 |
|
exception(*msg, **kwargs)
classmethod
Write exception.
src/view/_logging.py
295 296 297 298 |
|
info(*msg, **kwargs)
classmethod
Write info message.
src/view/_logging.py
275 276 277 278 |
|
warning(*msg, **kwargs)
classmethod
Write warning message.
src/view/_logging.py
280 281 282 283 |
|
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
301 302 303 304 |
|
Bases: _Logger
Logger to be seen by view.py developers for debugging purposes.
src/view/_logging.py
307 308 309 310 |
|
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
719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 |
|
__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
722 723 724 725 726 727 728 729 |
|
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
731 732 733 734 735 736 737 738 739 740 741 742 743 |
|
add_points(*args)
Add multiple points to the dataset.
src/view/_logging.py
745 746 747 748 |
|
HeatedProgress
Bases: Progress
Progress that changes color based on how close the bar is to completion.
src/view/_logging.py
827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 |
|
Internal
Bases: _Logger
Logger to be seen by view.py developers for debugging purposes.
src/view/_logging.py
307 308 309 310 |
|
LogPanel
Bases: Panel
Panel with limit on number of lines relative to the terminal size.
src/view/_logging.py
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 693 694 695 696 697 698 699 700 |
|
write(text)
Write text to the panel.
src/view/_logging.py
670 671 672 673 674 675 676 |
|
LogTable
Bases: Table
Table with limit on number of columns relative to the terminal height.
src/view/_logging.py
703 704 705 706 707 708 709 710 711 712 713 714 715 716 |
|
Plot
Plot renderable for rich.
src/view/_logging.py
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 798 799 800 801 802 803 804 805 |
|
__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
754 755 756 757 758 759 760 761 762 763 764 765 |
|
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
767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 |
|
Service
Bases: _Logger
Logger to be seen by the user when the app is running.
src/view/_logging.py
301 302 303 304 |
|
enter_server()
Start fancy mode.
src/view/_logging.py
997 998 999 1000 1001 1002 |
|
exit_server()
End fancy mode.
src/view/_logging.py
1005 1006 1007 |
|