stuff
This commit is contained in:
parent
76c2dedea3
commit
44703c5601
3 changed files with 27 additions and 20 deletions
|
|
@ -36,7 +36,9 @@ class CheckpointManager:
|
|||
write_yaml(
|
||||
path=self.file_path,
|
||||
data={
|
||||
CheckpointManager.highest_synced_timestamp_field_key: self.highest_synced_timestamp.isoformat()
|
||||
CheckpointManager.highest_synced_timestamp_field_key: self.highest_synced_timestamp.astimezone(
|
||||
tz=datetime.timezone.utc
|
||||
).isoformat()
|
||||
},
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,9 @@ import datetime
|
|||
import pathlib
|
||||
from dataclasses import dataclass
|
||||
|
||||
ASSUMED_PREHISTORICAL_DATETIME = datetime.datetime.fromtimestamp(0)
|
||||
ASSUMED_PREHISTORICAL_DATETIME = datetime.datetime.fromtimestamp(
|
||||
0, tz=datetime.timezone.utc
|
||||
)
|
||||
DESTINATION_COLUMN_NAME = "documents"
|
||||
DEFAULT_BATCH_SIZE = 100
|
||||
COSMOS_DB_TIMESTAMP_FIELD_KEY = "_ts"
|
||||
|
|
@ -10,17 +12,12 @@ COSMOS_DB_TIMESTAMP_FIELD_KEY = "_ts"
|
|||
|
||||
@dataclass
|
||||
class PATHS:
|
||||
logging_file: pathlib.Path = pathlib.Path("anaxi.log")
|
||||
|
||||
# Expand user is important. It will replace the user and give you the full
|
||||
# path. Stuff breaks without it.
|
||||
config_home_path: pathlib.Path = pathlib.Path("~/.anaxi/").expanduser()
|
||||
cosmos_db_config_file_path: pathlib.Path = config_home_path / pathlib.Path(
|
||||
"cosmos-db.yml"
|
||||
)
|
||||
postgres_config_file_path: pathlib.Path = config_home_path / pathlib.Path(
|
||||
"postgres.yml"
|
||||
)
|
||||
streams_config_file_path: pathlib.Path = config_home_path / pathlib.Path(
|
||||
"streams.yml"
|
||||
)
|
||||
checkpoints_folder_path: pathlib.Path = config_home_path / "checkpoints/"
|
||||
home_path: pathlib.Path = pathlib.Path("~/.anaxi/").expanduser()
|
||||
logging_file: pathlib.Path = home_path / pathlib.Path("anaxi.log")
|
||||
cosmos_db_config_file_path: pathlib.Path = home_path / pathlib.Path("cosmos-db.yml")
|
||||
postgres_config_file_path: pathlib.Path = home_path / pathlib.Path("postgres.yml")
|
||||
streams_config_file_path: pathlib.Path = home_path / pathlib.Path("streams.yml")
|
||||
checkpoints_folder_path: pathlib.Path = home_path / "checkpoints/"
|
||||
|
|
|
|||
|
|
@ -1,15 +1,23 @@
|
|||
import logging
|
||||
|
||||
from anaxi.constants import PATHS
|
||||
|
||||
|
||||
def get_anaxi_logger(name: str) -> None:
|
||||
logger = logging.getLogger(name)
|
||||
handler = logging.StreamHandler()
|
||||
handler.setFormatter(
|
||||
logging.Formatter(
|
||||
|
||||
anaxi_formatter = logging.Formatter(
|
||||
fmt="%(asctime)s - [%(levelname)s] - %(filename)s - L%(lineno)d - %(message)s"
|
||||
)
|
||||
)
|
||||
logger.addHandler(handler)
|
||||
|
||||
console_handler = logging.StreamHandler()
|
||||
console_handler.setFormatter(anaxi_formatter)
|
||||
logger.addHandler(console_handler)
|
||||
|
||||
file_handler = logging.FileHandler(filename=PATHS.logging_file)
|
||||
file_handler.setFormatter(anaxi_formatter)
|
||||
logger.addHandler(file_handler)
|
||||
|
||||
logger.setLevel(logging.INFO)
|
||||
|
||||
return logger
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue