API Reference
Logging Module
Logger class
Logging Levels
Logging level constants for the LogNGraph package.
This module defines standard logging levels used throughout the LogNGraph package. The levels follow a hierarchical structure where lower numerical values indicate more verbose logging.
- Constants:
- TRACE (int): Level 0 - Most detailed information for tracing program execution.DEBUG (int): Level 1 - Diagnostic information useful for debugging.INFO (int): Level 2 - General information about program execution.WARNING (int): Level 3 - Indicates potential issues that don’t prevent execution.ERROR (int): Level 4 - Errors that affect functionality but allow continued operation.FATAL (int): Level 5 - Critical errors that prevent further operation.NONE (int): Level 6 - Special value to disable all logging.
Example
>>> from logngraph.log import get_logger
>>> from logngraph.log.levels import INFO, DEBUG
>>> logger = get_logger(__name__, level=DEBUG)
>>> logger.set_level(INFO)
Note
These levels follow the standard syslog severity levels with the addition of TRACE for ultra-verbose logging and NONE for disabling logs.
- logngraph.log.levels.DEBUG = 1
Level 1 - Diagnostic information useful for debugging.
- Type:
int
- logngraph.log.levels.ERROR = 4
Level 4 - Errors that affect functionality but allow continued operation.
- Type:
int
- logngraph.log.levels.FATAL = 5
Level 5 - Critical errors that prevent further operation.
- Type:
int
- logngraph.log.levels.INFO = 2
Level 2 - General information about program execution.
- Type:
int
- logngraph.log.levels.NONE = 6
Level 6 - Special value to disable all logging.
- Type:
int
- logngraph.log.levels.TRACE = 0
Level 0 - Most detailed information for tracing program execution.
- Type:
int
- logngraph.log.levels.WARNING = 3
Level 3 - Indicates potential issues that don’t prevent execution.
- Type:
int
Graphics Module
Window Class
- class logngraph.graph.Window(title='Window', width=800, height=600, resizable=True)[source]
Bases:
object- Parameters:
title (str)
width (int)
height (int)
resizable (bool)
- __init__(title='Window', width=800, height=600, resizable=True)[source]
- Parameters:
title (str)
width (int)
height (int)
resizable (bool)
- Return type:
None
- bind_keydown(key, function, args=None)[source]
Bind given keypress to given function. Function will be called when the key is pressed.
- Parameters:
key (str) – Key press. Must be a valid pygame key name (e.g., ‘a’, ‘space’, ‘enter’).
function (Callable) – Function to call when the key is pressed.
args (Iterable[Any]) – Arguments to pass to the function.
- Returns:
None
- Return type:
None
- bind_keyup(key, function, args=None)[source]
Bind given keypress to given function. Function will be called when the key is pressed.
- Parameters:
key (str) – Key press. Must be a valid pygame key name (e.g., ‘a’, ‘space’, ‘enter’).
function (Callable) – Function to call when the key is pressed.
args (Iterable[Any]) – Arguments to pass to the function.
- Returns:
None
- Return type:
None
- circle(center, radius, color='#ffffff')[source]
Create circle with center at center and radius=radius.
- Parameters:
center (tuple[float, float] | Vec2D) – Center position of the circle.
radius (float) – Radius of the circle.
color – Fill color of the circle.
- Returns:
None
- Return type:
None
- fill(color)[source]
Fill the window with given color.
- Parameters:
color (tuple[int, int, int] | str) – Color to fill the window with.
- Returns:
None
- Return type:
None
- property height: int
- line(start_pos, end_pos, color='#ffffff', width=1)[source]
Draw a line from start_pos to end_pos with width=width and color=color.
- polygon(*args, color='#ffffff')[source]
Draw a polygon with given position arguments.
- Parameters:
args (float | tuple[float, float] | Vec2D) – x, y pairs of coordinates of the vertices of the polygon. E.g. (0, 0), (15, 60), (123, 624), or 0, 0, 15, 60, 123, 624.
color – Fill color of the polygon.
- Returns:
None
- Return type:
None
- rect(left_top, width_height, color='#ffffff')[source]
Draw a rectangle with given width and height and at given coordinates.
- screenshot(filename)[source]
Save a screenshot of the window to a file.
- Parameters:
filename (str) – Path to the file to save the screenshot to.
- Returns:
None
- Return type:
None
- property width: int
- write(center, text='', color='#ffffff', antialias=True, font='Arial', size=16)[source]
Write given text to the screen.
- Parameters:
center (tuple[int, int]) – Center position of the text.
text (str) – Text to write.
color – Color of the text.
antialias (bool) – Enable antialiasing of the text.
font (Font | str) – Font of the text.
size (int) – Font size of the text.
- Returns:
None
- Return type:
None