in hugegraph-ml/src/hugegraph_ml/models/seal.py [0:0]
def __init__(self, log_path=None, log_name="lightlog", log_level="debug"):
log_level = _transform_log_level(log_level)
if log_path:
if not log_path.endswith("/"):
log_path += "/"
if not os.path.exists(log_path):
os.mkdir(log_path)
if log_name.endswith("-") or log_name.endswith("_"):
log_name = (
log_path
+ log_name
+ time.strftime("%Y-%m-%d-%H:%M", time.localtime(time.time()))
+ ".log"
)
else:
log_name = (
log_path
+ log_name
+ "_"
+ time.strftime("%Y-%m-%d-%H-%M", time.localtime(time.time()))
+ ".log"
)
logging.basicConfig(
level=log_level,
format="%(asctime)s %(levelname)s: %(message)s",
datefmt="%Y-%m-%d-%H:%M",
handlers=[
logging.FileHandler(log_name, mode="w"),
logging.StreamHandler(),
],
)
logging.info("Start Logging")
logging.info("Log file path: %s", log_name)
else:
logging.basicConfig(
level=log_level,
format="%(asctime)s %(levelname)s: %(message)s",
datefmt="%Y-%m-%d-%H:%M",
handlers=[logging.StreamHandler()],
)
logging.info("Start Logging")