Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gsren 315 thread safe logging #50

Merged
merged 12 commits into from
Feb 26, 2025
Merged

Gsren 315 thread safe logging #50

merged 12 commits into from
Feb 26, 2025

Conversation

mki-c2c
Copy link
Contributor

@mki-c2c mki-c2c commented Feb 24, 2025

Refactoring to enable:

  • threadsafe logging
  • log filtering per data type (style, layer, meta) + frontend display
  • consistent logging interface

url=response.url,
data_type=self.context,
)
self.responses[self.id].append(api_record)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I understand, it is not really useful to keep track of logs not related to self.id.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, you are right the id is no longer useful since an independent LogHandler instance is attached to each request state

will fix

except AttributeError:
self.responses.append(None)
self.responses[self.id].append(
InfoRecord(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In which case this happens (AttributeError) ?
Is it really an info or an error ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this part is reached of extra=response is not added to the log (if there is a wrong version of the lib.
This cas will not be reached by design, but since the app cannot be sure if record contains a response or not, it will have to try. It is a root log message, so most likely the lib has something to say and it would be a pity to drop the message.
I would propably keep this code and add a comment


def get_json_responses(self) -> list[dict[str, Any]]:
return [self.json_response(r) for r in self.responses if r is not None]
def pop_properties(self) -> dict[str, Any]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a pop but a get.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, i was a pop and became a get

)
server=gs_info["url"],
user=gs_info["auth"] and gs_info["auth"].login,
err="Invalid credentials",
) from err
gs_logger.info(
"Session opened on %s at %s",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resp may be not associated with a value in following lines if status code is not 401.

missing a raise err ?

For example:

docker compose stop geoserver

Then run copy.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, reraise original error


const styleLogs = computed(() => logs.value.filter((l) => l.data_type == 'Style'))

const metaSuccessful = computed(() => metaLogs.value.some((l) => l.status == "OK"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No feedback here in case of error.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK added red cross

@mki-c2c mki-c2c merged commit c851d30 into main Feb 26, 2025
3 checks passed
@jeanmi151 jeanmi151 deleted the GSREN-315_thread_safe_logging branch February 27, 2025 08:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants