Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions usaspending_api/download/filestreaming/s3_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,5 @@ def get_simple_url(self, file_name):
Gets URL for read
"""
bucket_url = f"{settings.FILES_SERVER_BASE_URL}/{self.redirect_dir}/"
env_dir = ""
if self.redirect_dir == settings.BULK_DOWNLOAD_S3_REDIRECT_DIR and self.environment != "production":
# currently only downloads have a bucket per environment
env_dir = f"{self.environment}/"
generated = f"{bucket_url}{env_dir}{file_name}"
generated = f"{bucket_url}{file_name}"
return generated
54 changes: 40 additions & 14 deletions usaspending_api/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,14 @@
)

# S3 Bucket and Key to retrieve the Data Dictionary
DATA_DICTIONARY_S3_BUCKET_NAME = f"dti-da-public-files-{'nonprod' if CONFIG.ENV_CODE not in ('prd', 'stg') else 'prod'}"
DATA_DICTIONARY_S3_KEY = f"user_reference_docs/{DATA_DICTIONARY_FILE_NAME}"
DATA_DICTIONARY_S3_BUCKET_NAME = os.environ.get(
"DATA_DICTIONARY_S3_BUCKET_NAME",
f"dti-da-public-files-{'nonprod' if CONFIG.ENV_CODE not in ('prd', 'stg') else 'prod'}"
)
DATA_DICTIONARY_S3_KEY = os.environ.get(
"DATA_DICTIONARY_S3_BUCKET_NAME",
f"user_reference_docs/{DATA_DICTIONARY_FILE_NAME}"
)

# Local download files
IDV_DOWNLOAD_README_FILE_PATH = str(APP_DIR / "data" / "idv_download_readme.txt")
Expand Down Expand Up @@ -434,6 +440,36 @@ def _configure_database_connection(
logs_dir.mkdir(parents=True, exist_ok=True)
console_log_file_path.touch(exist_ok=True)

# Logging settings adjusted based on env
fapc = os.environ.get("FAPC", "")

if fapc:
server_handler = {
"level": "DEBUG",
"class": "logging.StreamHandler",
"stream": "ext://sys.stdout",
"formatter": "user_readable"
}
console_file_handler = {
"level": "DEBUG",
"class": "logging.StreamHandler",
"stream": "ext://sys.stdout",
"formatter": "specifics"
}
else:
server_handler = {
"level": "DEBUG",
"class": "logging.handlers.WatchedFileHandler",
"filename": str(APP_DIR / "logs" / "server.log"),
"formatter": "user_readable",
}
console_file_handler = {
"level": "DEBUG",
"class": "logging.handlers.WatchedFileHandler",
"filename": str(APP_DIR / "logs" / "console.log"),
"formatter": "specifics",
}

LOGGING = {
"version": 1,
"disable_existing_loggers": False,
Expand All @@ -460,18 +496,8 @@ def _configure_database_connection(
},
},
"handlers": {
"server": {
"level": "DEBUG",
"class": "logging.handlers.WatchedFileHandler",
"filename": str(APP_DIR / "logs" / "server.log"),
"formatter": "user_readable",
},
"console_file": {
"level": "DEBUG",
"class": "logging.handlers.WatchedFileHandler",
"filename": str(APP_DIR / "logs" / "console.log"),
"formatter": "specifics",
},
"server": server_handler,
"console_file": console_file_handler,
"console": {
"level": "DEBUG",
"class": "logging.StreamHandler",
Expand Down
Loading