Skip to content

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").

'Debug Console'
max_lines int

Maximum number of log lines to display (default: 200).

200
Example
import flet_onesignal as fos

logger = fos.setup_logging()
debug = fos.DebugConsole()

# Use icon in AppBar
page.appbar = ft.AppBar(
    title=ft.Text("My App"),
    actions=[debug.icon],
)

# Or use FAB
page.floating_action_button = debug.fab
Attributes#
MAX_DISPLAY_LINES class-attribute instance-attribute #
MAX_DISPLAY_LINES = 200

Maximum lines to display (performance limit).

fab property #
fab: FloatingActionButton

Get the FAB for use as floating action button.

icon property #
icon: IconButton

Get the debug icon for use in AppBar actions.

LogLevel #

Log level with associated Flet colors for the DebugConsole display.

Functions#
from_string classmethod #
from_string(level: str) -> LogLevel

Get LogLevel from string.

Functions#

get_log_path #

get_log_path() -> str

Get the log file path.

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: logging.INFO).

INFO
format_string str

Log format string using {}-style formatting.

'[{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.

Example
import flet_onesignal as fos

logger = fos.setup_logging()
logger.info("App started")