This would be ideal as loguru itself has a long list of dependencies including many test related ones that don't make sense to have in a core package. https://pypistats.org/packages/loguru
This could facilitate deeper including in ultralytics.
To replace Loguru with the default Python logging, you'll need to adjust your code to use the logging module instead of Loguru. Here's a step-by-step guide to help you make this transition:
Step 1: Import the logging module
import logging
Step 2: Configure the logging settings
You'll need to configure the logging settings to define the log level, format, and output destination. This setup can be done using logging.basicConfig() or by creating a custom configuration using logging.config.
Basic Configuration Example:
logging.basicConfig(
level=logging.DEBUG, # Set the log level
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', # Set the log format
datefmt='%Y-%m-%d %H:%M:%S', # Set the date format
handlers=[
logging.FileHandler("app.log"), # Log to a file
logging.StreamHandler() # Log to the console
]
)
Step 3: Create loggers
Replace Loguru logger instances with Python logging loggers.
Example of creating a logger:
logger = logging.getLogger(__name__)
Step 4: Replace Loguru logging calls with logging module calls
You'll need to replace all Loguru log calls (e.g., logger.debug, logger.info, logger.warning, logger.error, logger.critical) with the corresponding calls in the logging module.
Example of replacing Loguru log calls:
If your Loguru logging looked like this:
from loguru import logger
logger.debug("This is a debug message")
logger.info("This is an info message")
logger.warning("This is a warning message")
logger.error("This is an error message")
logger.critical("This is a critical message")
You would replace it with:
import logging
logger = logging.getLogger(__name__)
logger.debug("This is a debug message")
logger.info("This is an info message")
logger.warning("This is a warning message")
logger.error("This is an error message")
logger.critical("This is a critical message")
Full Example
Here is a full example showing how you might configure and use the default Python logging module:
import logging
# Configure logging
logging.basicConfig(
level=logging.DEBUG,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
datefmt='%Y-%m-%d %H:%M:%S',
handlers=[
logging.FileHandler("app.log"),
logging.StreamHandler()
]
)
# Create a logger
logger = logging.getLogger(__name__)
# Example log messages
logger.debug("This is a debug message")
logger.info("This is an info message")
logger.warning("This is a warning message")
logger.error("This is an error message")
logger.critical("This is a critical message")
By following these steps, you can replace Loguru with the default Python logging module. Make sure to review your entire codebase to update all instances where Loguru logging is used, replacing them with the appropriate logging module calls.
This would be ideal as
loguru
itself has a long list of dependencies including many test related ones that don't make sense to have in a core package. https://pypistats.org/packages/loguruThis could facilitate deeper including in
ultralytics
.To replace Loguru with the default Python logging, you'll need to adjust your code to use the
logging
module instead of Loguru. Here's a step-by-step guide to help you make this transition:Step 1: Import the logging module
Step 2: Configure the logging settings
You'll need to configure the logging settings to define the log level, format, and output destination. This setup can be done using
logging.basicConfig()
or by creating a custom configuration usinglogging.config
.Basic Configuration Example:
Step 3: Create loggers
Replace Loguru logger instances with Python
logging
loggers.Example of creating a logger:
Step 4: Replace Loguru logging calls with logging module calls
You'll need to replace all Loguru log calls (e.g.,
logger.debug
,logger.info
,logger.warning
,logger.error
,logger.critical
) with the corresponding calls in thelogging
module.Example of replacing Loguru log calls:
If your Loguru logging looked like this:
You would replace it with:
Full Example
Here is a full example showing how you might configure and use the default Python logging module:
By following these steps, you can replace Loguru with the default Python logging module. Make sure to review your entire codebase to update all instances where Loguru logging is used, replacing them with the appropriate logging module calls.