fix: configure logging for file-writing

This commit is contained in:
Marc 2024-07-06 16:37:10 -04:00
parent 807a4804ef
commit d1a2786c6e
Signed by: marc
GPG key ID: 048E042F22B5DC79

View file

@ -18,7 +18,10 @@ import pydantic
import boto3 import boto3
logger = logging.getLogger(__file__) logger = logging.getLogger(__file__)
logging.basicConfig(level=logging.INFO) logging.basicConfig(
filename="/var/log/backup-volumes.log", encoding="utf-8", level=logging.INFO
)
class Config(pydantic.BaseModel): class Config(pydantic.BaseModel):
# List of volumes to back up. # List of volumes to back up.
@ -62,6 +65,7 @@ if __name__ == "__main__":
config_path = sys.argv[1] config_path = sys.argv[1]
if not pathlib.Path(config_path).exists(): if not pathlib.Path(config_path).exists():
logger.error("Did not find configuration file at %s.", config_path)
raise RuntimeError(f"Did not find configuration at {config_path}") raise RuntimeError(f"Did not find configuration at {config_path}")
config = Config.parse_file(config_path) config = Config.parse_file(config_path)