Debug Console#
flet_onesignal.console
#
Debug Console module for flet-onesignal.
Provides visual debugging tools for viewing application logs directly in Flet apps during development. Includes file-based logging with rotation and a log viewer dialog with color-coded levels and filtering.
Classes#
DebugConsole
#
Lightweight debug console for viewing application logs.
Provides an icon (for AppBar) and a fab (floating action button) that
open a dialog showing application logs with color-coded levels and filtering.
Reads log entries written by setup_logging().
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title
|
str
|
Dialog title (default: |
'Debug Console'
|
max_lines
|
int
|
Maximum number of log lines to display (default: 200). |
200
|
Example
LogLevel
#
Functions#
setup_logging
#
setup_logging(
level: int = logging.INFO,
format_string: str = "[{asctime}] [{levelname}] [{filename}:{funcName}:{lineno}] - {message}",
max_bytes: int = 256 * 1024,
backup_count: int = 1,
) -> logging.Logger
Setup file-based logging with automatic rotation for use with DebugConsole.
Writes logs to the path specified by the FLET_APP_CONSOLE environment
variable, or to debug.log in the current directory, or to a temp file
as fallback.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
level
|
int
|
Logging level (default: |
INFO
|
format_string
|
str
|
Log format string using |
'[{asctime}] [{levelname}] [{filename}:{funcName}:{lineno}] - {message}'
|
max_bytes
|
int
|
Maximum log file size in bytes before rotation (default: 256 KB). |
256 * 1024
|
backup_count
|
int
|
Number of rotated backup files to keep (default: 1). |
1
|
Returns:
| Type | Description |
|---|---|
Logger
|
Configured logger instance. |