0314-python logger

PYTHON LEARNING

logging

import logging
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s')
# logging.basicConfig(level=logging.INFO, format='%(levelname)s - %(message)s')
logger = logging.getLogger(__name__)

use your own logger to avoid logging info from other package

import logging

# Step 1: Set the global logging level to suppress most external logging
logging.basicConfig(level=logging.CRITICAL)

# Step 2: Configure your application's logger for detailed logging
# Assuming 'my_app' is the name or base path of your application's loggers
my_app_logger = logging.getLogger('my_app')
my_app_logger.setLevel(logging.DEBUG)  # Or whatever level is appropriate for your app

# Set up a console handler (or any other handler) for your application's logger
console_handler = logging.StreamHandler()
console_handler.setLevel(logging.DEBUG)  # Ensure the handler also uses the desired level
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
console_handler.setFormatter(formatter)

# Add the handler to your application's logger
my_app_logger.addHandler(console_handler)

# Example usage
my_app_logger.debug('This debug message will be printed.')
my_app_logger.info('This info message will be printed.')

for simplicity

MEMO

freq,mapdepth,beam,nstd,lmax(numerical),lmax(PCL) 30, 10.6, 67, 1.5427, 750, 400 40, 10.6, 63, 1.5427, 800, 400 85, 1.72, 40, 0.2503, 1250, 750 95, 1.35, 30, 0.1965, 1650, 1000 145, 1.27, 19, 0.1848, >2000, 1750 155, 1.24, 17, 0.1804, >2000, 2000 215, 1.9, 11, 0.2765, >2000, 2000 270, 1.64, 9, 0.2387, >2000, 2000

Last updated