Skip to content

Conversation

ritankarsaha
Copy link
Contributor

Fixes #159

Description:-

This PR does the following:-

  1. Implemented Custom Logging for both the environments development and production.
  2. Three different custom formatters are defined in the LOGGING dictionary - simple, verbose, and detailed.
  3. Two different handlers defined, one for showing logs in the terminal which is to be used in development, and one for storing logs in the file, which is to be used in production.
  4. Added a dateformat to all formatters with asctime to exclude miliseconds from asctime.
  5. Added a check for logs directory to make one if it doesn't exist as it can create issues on different os.

PROOF OF WORK:-

Screen.Recording.2024-06-21.at.7.mp4

Thank You.

@ritankarsaha
Copy link
Contributor Author

@SamakshAgarwal1112 I have fixed the issue #159 and opened a PR for the same #160

@SamakshAgarwal1112
Copy link
Collaborator

@ritankarsaha Good work. Although a few changes are required!!

  • Remove unused imports at the top of common.py
  • You have created two loggers which are both doing the same thing. Only keep the django one. Remove the first one.
  • In the loggers, you have defined django. Instead django, when you define level, do level INFO for development environment and WARNING for production.
  • The detailed format should be more clearer. Right now, person viewing it won't be able to tell what is what. Try to get it in the following style:
    Level -
    Time -
    Module -
    PID -
    TID -
    Message -
    [One-line-gap]
  • Instead of a single file logs/alumni_connect.log, make three different ones logs/warning.log, logs/error.log and logs/critical.log storing their respective level logs. No need for info.log or debug.log as we won't be needing those.

@ritankarsaha
Copy link
Contributor Author

@SamakshAgarwal1112 Made the necessary changes and pushed a new commit into the PR.
This commit now ensures:-

  1. Removed unused imports at the top of common.py
  2. Only kept the django logger. Removed the first one.
  3. The detailed format is now like this : -
    Level -
    Time -
    Module -
    PID -
    TID -
    Message -
    [One-line-gap]
  4. Instead of a single file logs/alumni_connect.log, made three different ones logs/warning.log, logs/error.log and logs/critical.log for storing their respective level logs.

PROOF OF WORK

Screen.Recording.2024-06-22.at.11.mp4

@SamakshAgarwal1112
Copy link
Collaborator

@ritankarsaha Good work. A last few changes are required.

  • Remove the last 4 lines in your code. Those logs are not really required.
  • Also, currently, your segregation of log levels in different files is not specific. For example, in warning.log, you are storing all logs above the warning level in that file. Make only store that particular level in that file. You can define filters for the following.

@ritankarsaha
Copy link
Contributor Author

@SamakshAgarwal1112 Added the filters, and made the changes as asked.

PROOF OF WORK

Screen.Recording.2024-06-22.at.7.mp4

Thank You

@SamakshAgarwal1112
Copy link
Collaborator

SamakshAgarwal1112 commented Jun 22, 2024

@ritankarsaha LGTM. Just change the way you are choosing handlers and their levels. Currently, You are checking if the environment is development, rather you should check if the environment is production, and choose according to that.

@ritankarsaha
Copy link
Contributor Author

@ritankarsaha LGTM. Just change the way you are choosing handlers and their levels. Currently, You are checking if the environment is development, rather you should check if the environment is production, and choose according to that.

@SamakshAgarwal1112 Made the necessary changes and pushed a new commit into the PR.
Now while choosing the handlers and their levels it checks first if the env is production.
I have also made additional changes in the level section as well. It too checks production first.

Thank You.

@ritankarsaha
Copy link
Contributor Author

@SamakshAgarwal1112 used os.environ.get() instead of os.getenv() for checking variables while still in production.

@SamakshAgarwal1112
Copy link
Collaborator

@ritankarsaha Good work.

@SamakshAgarwal1112 SamakshAgarwal1112 merged commit 21c49a4 into BitByte-TPC:master Jun 24, 2024
@SamakshAgarwal1112 SamakshAgarwal1112 added difficulty - medium BSoC'24 Issues available during BSoC 2024 labels Jun 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BSoC'24 Issues available during BSoC 2024 difficulty - medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Implement logic for custom logging.

2 participants