Skip to content

Add log info about download#275

Open
illya-havsiyevych wants to merge 8 commits into1.1.xfrom
feat/log-download
Open

Add log info about download#275
illya-havsiyevych wants to merge 8 commits into1.1.xfrom
feat/log-download

Conversation

@illya-havsiyevych
Copy link
Contributor

@illya-havsiyevych illya-havsiyevych commented Jun 12, 2025

Universal approach to just log submit info about downloads. Should work with anonymous and real user

{
	"message": "forwardDownload",
	"context": {
		"uri": "/workspaces/default:SwissRe/engine/data/async/submit",
		"body": "{\"_type\":\"SdmxTableDataQueryPlusV2\",\"includeHistory\":\"false\",\"dimensionAtObservation\":\"TIME_PERIOD\",\"messageVersion\":\"2.0.0\",\"outputFormat\":\"EXCEL\",\"viewMode\":\"TIMESERIES_PER_ROW\",\"agencyID\":\"SWRE\",\"resourceID\":\"STANDARD_INSURANCE_DATA\",\"version\":\"2.0.1\",\"columns\":[{\"componentId\":\"FREQUENCY\",\"value\":\"name\",\"header\":\"name\"},{\"componentId\":\"COUNTRY\",\"value\":\"name\",\"header\":\"name\"},{\"componentId\":\"SERIES\",\"value\":\"name\",\"header\":\"name\"},{\"componentId\":\"SOURCE\",\"value\":\"name\",\"header\":\"name\"},{\"componentId\":\"BUSINESS_LINE\",\"value\":\"name\",\"header\":\"name\"}],\"filters\":[{\"componentCode\":\"TIME_PERIOD\",\"operator\":\"ge\",\"value\":\"631152000000\"},{\"componentCode\":\"TIME_PERIOD\",\"operator\":\"le\",\"value\":\"2082844799999\"}],\"headerConfig\":{\"languages\":[\"en\"]},\"limit\":null,\"rows\":[{\"componentId\":\"OBS_VALUE\"}]}",
		"user": "Illya Havsiyevych",
		"email": "Illya_Havsiyevych@epam.com"
	},
	"level": 200,
	"level_name": "INFO",
	"channel": "quanthub_sdmx_proxy",
	"datetime": "2025-06-13T06:45:57.620595+02:00",
	"extra": {
		"referer": "https://quanthub-portals-swiss-re.imf-eid.projects.epam.com/explorer",
		"ip": "10.0.0.205",
		"request_uri": "https://quanthub-portals-swiss-re.imf-eid.projects.epam.com/sdmx-download/workspaces/default:SwissRe/engine/data/async/submit",
		"uid": "77",
		"user": "Illya_Havsiyevych@epam.com"
	}
}

@illya-havsiyevych illya-havsiyevych requested a review from drudoi June 12, 2025 16:49
$uid = $this->currentUser->id();
$user = $this->userStorage->load($uid);
$context['user'] = $user->getDisplayName();
$context['email'] = $user->getEmail();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Log PII data is unsafe. `$context['uid'] is already in the context and it should be enough for technical info.

$context['user'] = $user->getDisplayName();
$context['email'] = $user->getEmail();
}
$this->loggerFactory->get('quanthub_sdmx_proxy')->info('forwardDownload', $context);
Copy link
Collaborator

Choose a reason for hiding this comment

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

  1. I propose define human-readable messages.
  2. May be ->debug() level is better.

$context = [];
$context['uri'] = $uri;
if ($body = $request->getContent()) {
$context['body'] = $body;
Copy link
Collaborator

Choose a reason for hiding this comment

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

"body" context isn't supported by Drupal loggers, let use "%body" variable.

*/
private $foundationFactory;

private const DOWNLOAD_SUBMIT_PATH = '/submit';
Copy link
Collaborator

Choose a reason for hiding this comment

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

The constant is used once, I propose have string in place.

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