Logging and diagnostics

PyMemoryEditor uses the standard logging module to emit informational messages from inside its scans. By default, the library is silent β€” a NullHandler is attached so nothing is printed unless you opt in.

Turning logging on

To see what the library is doing internally, attach a handler to the PyMemoryEditor logger:

import logging

logging.basicConfig(level=logging.DEBUG)
logging.getLogger("PyMemoryEditor").setLevel(logging.DEBUG)

You’ll start seeing messages like:

DEBUG    PyMemoryEditor: skipping region 0x7FFD0000–0x7FFD2000 (read failed)
WARNING  PyMemoryEditor: mach_vm_protect could not restore protection at 0x14010F4F4

Log levels

LevelWhen it fires
DEBUGTransient skips during enumeration/scans (pages vanished mid-scan, unreadable chunks, a thread/module/image that couldn't be read).
WARNINGSurprising-but-recovered conditions β€” currently the macOS mach_vm_protect restore failure after a write to a read-only page.

Note

A partial read (fewer bytes returned than requested) is not a log event β€” it raises OSError so you never silently decode a half-populated buffer.

Routing logs

You can route the logger anywhere you like β€” to a file, to a Qt widget, to a remote log collector:

import logging

logger = logging.getLogger("PyMemoryEditor")
handler = logging.FileHandler("memscan.log")
handler.setFormatter(logging.Formatter("%(asctime)s %(levelname)s %(message)s"))
logger.addHandler(handler)
logger.setLevel(logging.DEBUG)

The bundled GUI app

The GUI app exposes the same log stream in its Log Console:

MenuTools β†’ Log Console

Toggling DEBUG verbosity in the console reveals the same messages the library sends to the Python logger.

macOS write-side-effect warning

On macOS, writing to a read-only page transparently elevates the page protection, performs the write, and tries to restore the original protection. If the restore step fails, the library emits a ResourceWarning and the target page is left more permissive than it started.

import warnings

# Treat the warning as an error so you don't miss it.
warnings.filterwarnings("error", category=ResourceWarning)

See Platform Notes β†’ macOS for the details.

See also