Skip to content

Commit

Permalink
perf($db): refine ORM log when initializing db
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnymillergh committed Nov 7, 2021
1 parent ae56fe5 commit 5fd5b1f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
3 changes: 2 additions & 1 deletion home_guardian/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@

# Set up logging
logging_conf_path = f"{get_root_path()}/logging.conf"
print(f"logging_conf_path = {logging_conf_path}, __file__ = {__file__}")
print(f"Start loading logging configuration. logging_conf_path = {logging_conf_path}, __file__ = {__file__}")
logging.config.fileConfig(logging_conf_path)
print(f"Done loading logging configuration.")
13 changes: 8 additions & 5 deletions home_guardian/repository/model/base/model.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
from peewee import Model, SqliteDatabase
import logging

from peewee import Model, SqliteDatabase
from home_guardian.function_collection import get_root_path

base_dir = get_root_path()
print(f"base_dir: {base_dir}")
db = SqliteDatabase(f"{base_dir}/home_guardian.db")
print(f"Initialized db file: {db}")
log = logging.getLogger("rotatingFileLogger")

db_path = f"{get_root_path()}/home_guardian.db"
log.info(f"SQLite database path: {db_path}")
db = SqliteDatabase(db_path)
log.info(f"Initialized db file: {db}")


class BaseModel(Model):
Expand Down

0 comments on commit 5fd5b1f

Please sign in to comment.