# Outfancy Python Logging Integration: A Complete Guide to Standard Library Compatibility

> Learn how Outfancy integrates with Python's standard logging module. Configure and use Outfancy with familiar logging methods, handlers, and formatters for seamless compatibility.

- Repository: [Carlos A. Planchón/outfancy](https://github.com/carlosplanchon/outfancy)
- Tags: how-to-guide
- Published: 2026-02-26

---

**Yes, Outfancy integrates natively with Python's standard `logging` module by instantiating a dedicated logger named `outfancy` that supports standard configuration methods, handlers, and formatters.**

Outfancy is a Python library for rendering fancy terminal tables maintained in the `carlosplanchon/outfancy` repository. According to the source code, the library does not implement a custom logging solution; instead, it creates a standard `logging.Logger` instance that follows Python's normal hierarchy, allowing you to control diagnostic output using familiar APIs like `logging.getLogger()`, `setLevel()`, and custom handlers.

## How Outfancy Implements Python Logging

The library's logging infrastructure is initialized lazily when you import submodules like `outfancy.table`. Unlike libraries that ship with rigid logging configurations, Outfancy exposes a standard logger that behaves exactly like any other Python logger.

### Logger Creation in [`outfancy/table.py`](https://github.com/carlosplanchon/outfancy/blob/main/outfancy/table.py)

In [`outfancy/table.py`](https://github.com/carlosplanchon/outfancy/blob/main/outfancy/table.py) at lines 14-21, the library creates its dedicated logger using the standard library approach:

```python
logger = logging.getLogger('outfancy')
logger.setLevel(logging.WARNING)
logger.propagate = False

```

This instantiation makes the logger available throughout the codebase for internal diagnostics. All internal messages—whether debug traces, informational notes, warnings, or errors—are emitted through this single logger instance using standard calls like `logger.debug()`, `logger.info()`, and `logger.warning()`.

### Default Handler Configuration

If the `outfancy` logger has no handlers attached at import time, the library automatically adds a simple `StreamHandler` to ensure messages are visible. The default configuration sets the level to `WARNING` and disables propagation to prevent duplicate logs in root logger configurations. You can verify this behavior in [`outfancy/table.py`](https://github.com/carlosplanchon/outfancy/blob/main/outfancy/table.py) where the library checks `if not logger.handlers:` before attaching the default stream handler.

## Configuring the Outfancy Logger

Because `outfancy` is a standard logger instance, you can reconfigure it without importing any special utilities from the library. Any changes you make via `logging.getLogger('outfancy')` will immediately affect the library's output behavior.

### Adjusting Log Levels

To enable verbose debugging for troubleshooting table rendering issues:

```python
import logging
import outfancy.table as ft

# Show every log message from Outfancy

logging.getLogger('outfancy').setLevel(logging.DEBUG)

tbl = ft.Table()
print(tbl.render([('A', 1), ('B', 2)]))

```

This exposes internal diagnostic calls such as `logger.debug(f"check_data = {self.check_data}")` found in the `show_check_data` method.

### Attaching Custom Handlers

You can replace the default stream handler with file handlers, rotating file handlers, or JSON formatters. First, clear the default handlers, then attach your own:

```python
import logging
import outfancy.table as ft

logger = logging.getLogger('outfancy')
logger.setLevel(logging.INFO)                       # show INFO and above

logger.handlers.clear()                             # remove the default stream handler

file_handler = logging.FileHandler('outfancy.log')
formatter = logging.Formatter('%(asctime)s %(levelname)s %(name)s: %(message)s')
file_handler.setFormatter(formatter)
logger.addHandler(file_handler)

tbl = ft.Table()
tbl.render([('Alpha', 10, '2026-01-01')])

```

## Practical Code Examples

### Using `dictConfig` for Production Setups

For complex applications using `logging.config.dictConfig`, treat the `outfancy` logger like any other component. This example configures a rotating file handler with 1MB size limits:

```python
import logging.config
import outfancy.table as ft

LOGGING = {
    "version": 1,
    "disable_existing_loggers": False,
    "loggers": {
        "outfancy": {
            "level": "DEBUG",
            "handlers": ["rotating"],
            "propagate": False,
        },
    },
    "handlers": {
        "rotating": {
            "class": "logging.handlers.RotatingFileHandler",
            "filename": "outfancy.log",
            "maxBytes": 1024 * 1024,
            "backupCount": 3,
            "formatter": "standard",
        },
    },
    "formatters": {
        "standard": {
            "format": "%(asctime)s %(levelname)s %(name)s: %(message)s"
        },
    },
}
logging.config.dictConfig(LOGGING)

tbl = ft.Table()
tbl.render([('X', 42), ('Y', 99)])

```

### Silencing Outfancy in Production

To completely suppress Outfancy output without modifying library code:

```python
import logging
logging.getLogger('outfancy').setLevel(logging.CRITICAL)

```

Alternatively, you can disable the logger entirely with `logging.getLogger('outfancy').disabled = True`.

## Key Source Files

Understanding the following files helps when debugging logging behavior:

- **[`outfancy/table.py`](https://github.com/carlosplanchon/outfancy/blob/main/outfancy/table.py)**: Contains the core logger creation at lines 14-21, default handler setup, and all internal log calls (`logger.debug`, `logger.warning`, etc.) throughout the `Table` and `LargeTable` classes.
- **[`LOGGING.md`](https://github.com/carlosplanchon/outfancy/blob/main/LOGGING.md)**: The repository's user-facing documentation file that provides quick-start snippets for customizing or disabling the logger.
- **[`outfancy/__init__.py`](https://github.com/carlosplanchon/outfancy/blob/main/outfancy/__init__.py)**: The package entry point where logging is configured lazily upon submodule import.

## Summary

- Outfancy creates a standard Python logger named `outfancy` in [`outfancy/table.py`](https://github.com/carlosplanchon/outfancy/blob/main/outfancy/table.py) using `logging.getLogger()`.
- The default configuration sets the level to `WARNING`, disables propagation, and adds a `StreamHandler` only if no handlers exist.
- You can control the logger using standard APIs: `setLevel()`, `addHandler()`, and `logging.config.dictConfig`.
- Internal library diagnostics use standard methods like `logger.debug()` and `logger.info()`, visible when you lower the log level.
- The [`LOGGING.md`](https://github.com/carlosplanchon/outfancy/blob/main/LOGGING.md) file in the repository provides additional configuration examples.

## Frequently Asked Questions

### What is the default log level for Outfancy?

The default log level is `WARNING`, as explicitly set in [`outfancy/table.py`](https://github.com/carlosplanchon/outfancy/blob/main/outfancy/table.py) during logger initialization. This means only warnings and errors are emitted unless you reconfigure the logger using `logging.getLogger('outfancy').setLevel()`.

### How do I disable Outfancy logging completely?

Set the logger level to `CRITICAL` or disable it entirely. Because `CRITICAL` is the highest standard level and Outfancy does not use it for routine messages, `logging.getLogger('outfancy').setLevel(logging.CRITICAL)` effectively silences all output. Alternatively, set `logging.getLogger('outfancy').disabled = True`.

### Can I redirect Outfancy logs to a file instead of the console?

Yes. Clear the existing handlers with `logger.handlers.clear()`, then attach a `logging.FileHandler` or `RotatingFileHandler`. Since the logger follows standard Python conventions, any handler compatible with the `logging` module works with Outfancy.

### Does Outfancy support structured logging formats like JSON?

Yes. Because Outfancy uses a standard `logging.Logger` instance, you can attach any formatter, including JSON formatters from libraries like `python-json-logger`. Simply create a handler with your custom formatter and add it to the `outfancy` logger via `logger.addHandler()`.