Outfancy uses Python's standard logging module for all internal logging.
By default, outfancy only shows WARNING and higher level logs. To enable more detailed logging:
import logging
import outfancy.table
# Enable DEBUG logging to see everything
logging.getLogger('outfancy').setLevel(logging.DEBUG)
# Or set to INFO for less verbosity
logging.getLogger('outfancy').setLevel(logging.INFO)
# Now use outfancy normally
table = outfancy.table.Table()
result = table.render(data)Outfancy uses the following log levels:
Detailed information for diagnosing issues:
- Function entry/exit points
- Configuration values
- Internal calculations
# Example output:
# 2026-02-03 18:18:08 - outfancy - DEBUG - Starting Table.render()
# 2026-02-03 18:18:08 - outfancy - DEBUG - check_data = False
# 2026-02-03 18:18:08 - outfancy - DEBUG - LargeTable rendering 3 rowsConfirmation that things are working as expected:
- Successful rendering completions
- Major operations completed
# Example output:
# 2026-02-03 18:18:08 - outfancy - INFO - LargeTable rendered 3 rows successfullyIndication that something unexpected happened, but the library handled it:
- Parameters were rebuilt automatically
- Non-optimal configurations detected
- Fallback behaviors triggered
# Example output:
# 2026-02-03 18:18:08 - outfancy - WARNING - label_list was rebuiltA more serious problem occurred, but execution continued:
- Invalid data detected
- Required parameters missing and couldn't be rebuilt
- Validation failures
# Example output:
# 2026-02-03 18:18:08 - outfancy - ERROR - Data integrity check failedYou can customize the logging format and handlers:
import logging
# Get the outfancy logger
logger = logging.getLogger('outfancy')
# Remove default handler if you want custom formatting
logger.handlers.clear()
# Add your own handler with custom formatting
handler = logging.StreamHandler()
formatter = logging.Formatter(
'%(levelname)s [%(name)s]: %(message)s'
)
handler.setFormatter(formatter)
logger.addHandler(handler)
# Set level
logger.setLevel(logging.DEBUG)import logging
logger = logging.getLogger('outfancy')
logger.setLevel(logging.DEBUG)
# Add file handler
file_handler = logging.FileHandler('outfancy.log')
file_handler.setFormatter(
logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')
)
logger.addHandler(file_handler)To completely silence outfancy logs:
import logging
logging.getLogger('outfancy').setLevel(logging.CRITICAL)
# Or
logging.getLogger('outfancy').disabled = TrueAll show_* methods now return values instead of printing:
# Old behavior (printed to console):
table.show_check_data() # Printed: False
# New behavior (returns value):
value = table.show_check_data() # Returns: False
print(value) # You control outputThe methods still log at DEBUG level for debugging purposes.
Now returns a string instead of printing directly:
# Old behavior (printed directly):
large = LargeTable()
large.render(data) # Printed to stdout
# New behavior (returns string):
large = LargeTable()
result = large.render(data) # Returns string
print(result) # You control when to print- Development: Use
DEBUGlevel to see everything - Production: Use
WARNINGlevel (default) to only see issues - Testing: Use
ERRORlevel to only see actual problems - Custom handlers: Add file handlers in production for log persistence
- Per-module logging: You can set different levels for different parts of your app
import logging
import outfancy.table
# Configure logging for production
logger = logging.getLogger('outfancy')
logger.setLevel(logging.WARNING)
# Add file handler for errors
error_handler = logging.FileHandler('outfancy_errors.log')
error_handler.setLevel(logging.ERROR)
error_handler.setFormatter(
logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')
)
logger.addHandler(error_handler)
# Use library normally
table = outfancy.table.Table()
result = table.render(data)