Skip to content

Commit

Permalink
[app][rfct] change logging
Browse files Browse the repository at this point in the history
  • Loading branch information
M3ssman committed Aug 30, 2024
1 parent 1bdd67a commit 94957e6
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/digiflow/record/record_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,6 @@ def do_GET(self):
if command is not None and command == DEFAULT_COMMAND_NEXT:
state, data = self.get_next_record(file_name, client_name,
get_record_state, set_record_state)
self.log("get '%s': '%s'", get_record_state, data,
level=logging.DEBUG)
if isinstance(data, str):
self._set_headers(state, _MIME_TXT)
self.wfile.write(data.encode('utf-8'))
Expand Down Expand Up @@ -154,13 +152,12 @@ def get_next_record(self, file_name, client_name, requested_state, set_state) ->
* inside this record list are open records available
"""

self.log("get %s from %s", file_name, self.record_list_directory)
data_file_path = self.get_data_file(file_name)
# no match results in 404 - resources not available after all
if data_file_path is None:
self.log("no '%s' found in '%s'", file_name, self.record_list_directory,
self.log("no %s found in %s", file_name, self.record_list_directory,
level=logging.WARNING)
return (404, f"no file '{file_name}' in {self.record_list_directory}")
return (404, f"no '{file_name}' in {self.record_list_directory}")

handler = df_r.RecordHandler(data_file_path, transform_func=df_r.row_to_record)
next_record = handler.next_record(requested_state)
Expand All @@ -185,7 +182,7 @@ def update_record(self, data_file, in_data) -> tuple:
data_file_path = self.get_data_file(data_file)
if data_file_path is None:
self.log('%s not found', data_file_path, level=logging.ERROR)
return (404, f"file not found: {data_file_path}")
return (404, f"{data_file_path} not found")
try:
handler = df_r.RecordHandler(data_file_path)
if isinstance(in_data, dict):
Expand All @@ -201,7 +198,7 @@ def update_record(self, data_file, in_data) -> tuple:
self.log(msg)
return (200, msg)
except RuntimeError as _rer:
msg = f"set {in_ident} to {in_state} in '{data_file_path}' failed: {_rer.args[0]}"
msg = f"set {in_ident} to {in_state} in {data_file_path} failed: {_rer.args[0]}"
self.log(msg, level=logging.ERROR)
return (500, msg)

Expand Down

0 comments on commit 94957e6

Please sign in to comment.