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

Added logging to both backend and frontend #15

Closed
wants to merge 2 commits into from

Conversation

anirudhprabhakaran3
Copy link
Member

Description

Adds logging of all requests to NGINX, frontend and backend.

Dependencies

For frontend, the package winston is used for logging requests.

Type of Change

What types of changes does your code introduce?
Put an x in the boxes that apply

  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Please also list any relevant details for your test configuration. (for bug fix / breaking change)
Put an x in the boxes that apply

  • Checked console logs to see if logs are coming up.

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@nishant-nayak
Copy link
Member

Logs on the backend look proper, logs on the frontend are a bit weird.

I think SvelteKit does some optimizations wherein if a page is loaded once and you nav away from it and nav back (without browser reload), it doesn't log any subsequent attempts to load the older pages (probably because it has rendered the page once already and just has to alter something locally).

This seems to be the case for both Winston and nginx. To replicate:

  1. Load the Home page. Logs are generated for this event.
  2. Navigate to the Design System Page from the navbar. Logs are also generated for this event.
  3. Navigate back to the Home page from the navbar. Not sure about this one, sometimes the logs were generated for this event too.
  4. Navigate to the Design System Page again from the navbar. Logs don't generate for this event.

Try this out and see if you're facing the same error? If that is the case, we'll have to further explore how to accurately gather logs from the frontend.

self.logger = logging.getLogger(__name__)

def __call__(self, request):
self.logger.info(request.__dict__)
Copy link
Member

Choose a reason for hiding this comment

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

The log output here currently seems to be a Python object. The output has certain fields like: 'wsgi.input': < django.core.handlers.wsgi.LimitedStream object at 0x7f4f3e9e66b0 >. Would it be possible to generate a JSON output for the same? I tried a simple json.dumps but that didn't seem to work directly.

@anirudhprabhakaran3
Copy link
Member Author

Closing this specific issue since no longer supported, but will note these points when we add logging.

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