Skip to content

Instantly share code, notes, and snippets.

@kevin85421
Created November 27, 2024 04:36
Show Gist options
  • Save kevin85421/9cf6ee70ceec42be3de888174d0c8e6a to your computer and use it in GitHub Desktop.
Save kevin85421/9cf6ee70ceec42be3de888174d0c8e6a to your computer and use it in GitHub Desktop.
import logging
import logging.config
ray_data_logger_config = {
"version": 1,
"disable_existing_loggers": False,
"formatters": {
"default": {
"format": "%(asctime)s - %(name)s - %(levelname)s - %(message)s",
},
},
"handlers": {
"console": {
"class": "logging.StreamHandler",
"formatter": "default",
"level": "INFO",
},
},
"loggers": {
"Ray.data": {
"handlers": ["console"],
"level": "INFO",
"propagate": False,
},
},
}
logging.config.dictConfig(ray_data_logger_config)
ray_data_logger = logging.getLogger("Ray.data")
ray_data_logger.info("This is an INFO log from Ray.data.")
ray_data_logger.warning("This is a WARNING log from Ray.data.")
ray_data_logger.info(f"Ray data propagate {ray_data_logger.propagate}")
ray_logger_config = {
"incremental": True,
"version": 1,
"disable_existing_loggers": False,
"formatters": {
"default": {
"format": "abc %(name)s - %(levelname)s - %(message)s",
},
},
"handlers": {
"console": {
"class": "logging.StreamHandler",
"formatter": "default",
"level": "DEBUG",
},
},
"loggers": {
"Ray": {
"handlers": ["console"],
"level": "DEBUG",
"propagate": False,
},
},
}
logging.config.dictConfig(ray_logger_config)
ray_logger = logging.getLogger("Ray")
ray_logger.debug("This is a DEBUG log from Ray.")
ray_logger.error("This is an ERROR log from Ray.")
ray_data_logger.info("Another INFO log from Ray.data.")
ray_data_logger.info(f"Ray data propagate {ray_data_logger.propagate}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment