Skip to content
This repository was archived by the owner on Aug 4, 2021. It is now read-only.

Commit ddd3a3e

Browse files
committed
fixing some of the logging.
set logging using LOG_LEVEL
1 parent dfa88c9 commit ddd3a3e

File tree

4 files changed

+13
-17
lines changed

4 files changed

+13
-17
lines changed

swift_upload_runner/download.py

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222

2323
LOGGER = logging.getLogger(__name__)
24-
LOGGER.setLevel(logging.DEBUG)
24+
LOGGER.setLevel(os.environ.get('LOG_LEVEL', 'INFO'))
2525

2626

2727
# Unlike other classes, download uses python-requests for fetching objects
@@ -105,11 +105,9 @@ def download_into_queue(
105105
object_name: str
106106
) -> None:
107107
"""Download object chunks from stream into the queue."""
108-
print(f"""
109-
Downloading from project {project},
110-
from container {container},
111-
the file {object_name}
112-
""")
108+
LOGGER.info(f"Downloading from project {project}, "
109+
f"from container {container}, "
110+
f"the file {object_name}")
113111
with requests.get(
114112
generate_download_url(
115113
get_download_host(self.auth, project),
@@ -123,10 +121,7 @@ def download_into_queue(
123121
stream=True,
124122
verify=True
125123
) as req:
126-
print(f"""
127-
Request headers:
128-
{req.headers}
129-
""")
124+
LOGGER.info(f"Request headers: {req.headers}")
130125
try:
131126
self.content_type = req.headers["Content-Type"]
132127
except KeyError:
@@ -340,10 +335,10 @@ def _parse_archive_fs(
340335
"""Parse a list of paths into a dict representing a filesystem."""
341336
ret_fs: dict = {}
342337
for path in to_parse:
343-
print(path)
338+
LOGGER.info(f"working path: {path}")
344339
# Path of zero means an incorrect input
345340
if len(path) == 0:
346-
raise ValueError("Tried to archive a file wihtout a name")
341+
raise ValueError("Tried to archive a file without a name")
347342
# Path of > 1 implies a directory in between
348343
# Create TarInfo for the directory
349344
if len(path) > 1:
@@ -484,7 +479,7 @@ def tar_archiving_loop(
484479

485480
next_file["fileobj"].begin_download()
486481

487-
print(f"""
482+
LOGGER.info(f"""
488483
Writing file {next_file["tar_info"].name} into the archive.
489484
""")
490485

swift_upload_runner/replicate.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import logging
55
import typing
6-
6+
import os
77
import aiohttp.web
88
import aiohttp.client
99

@@ -14,7 +14,7 @@
1414
import certifi
1515

1616
LOGGER = logging.getLogger(__name__)
17-
LOGGER.setLevel(logging.DEBUG)
17+
LOGGER.setLevel(os.environ.get('LOG_LEVEL', 'INFO'))
1818

1919
ssl_context = ssl.create_default_context()
2020
ssl_context.load_verify_locations(certifi.where())

swift_upload_runner/server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424

2525
logging.basicConfig(
26-
level=int(os.environ.get("UPLOAD_RUNNER_LOG_LEVEL", 20))
26+
level=os.environ.get('LOG_LEVEL', 'INFO')
2727
)
2828

2929

swift_upload_runner/upload.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323

2424
LOGGER = logging.getLogger(__name__)
25-
LOGGER.setLevel(logging.DEBUG)
25+
LOGGER.setLevel(os.environ.get('LOG_LEVEL', 'INFO'))
2626

2727

2828
# The upload process needs a generous timeout, due to aiohttp having a
@@ -203,6 +203,7 @@ async def a_add_manifest(
203203
) -> None:
204204
"""Add manifest file after segmented upload finish."""
205205
manifest = f"{self.container}_segments/{self.path}/"
206+
LOGGER.info(f"Add manifest to {self.container}_segments.")
206207
async with self.client.put(
207208
common.generate_download_url(
208209
self.host,

0 commit comments

Comments
 (0)