center-randomize icon indicating copy to clipboard operation
center-randomize copied to clipboard

[FEAT] Added custom logger function

Open yubinkarki opened this issue 10 months ago • 5 comments

Added a module under the utils directory to create a slightly customized logger function. Replaced the 4 print statements at the end of the main file with the logger.

How to use:

  • Import the setup_logger function in the desired module
  • Call the function with the name of the current module
  • Use the logger with appropriate loging level

Screenshot: image

yubinkarki avatar Apr 20 '24 13:04 yubinkarki

I'd recommend using loguru for efficiency and avoiding any bugs on custom implementation.

NISH1001 avatar Apr 20 '24 20:04 NISH1001

I'd recommend using loguru for efficiency and avoiding any bugs on custom implementation.

I think Python builtin logging module is quite self sufficient for the current use case and it just needs the configuration. Also works across all platform, it's best to avoid additional package for the same. It might be a bit overkill

horrormyth avatar Apr 20 '24 21:04 horrormyth

Working on it.

yubinkarki avatar Apr 21 '24 03:04 yubinkarki

Changes made:

  • Used logging.config.dictConfig to configure the logger with custom options.
  • Called the logger config function at the top of school_center.py file.
  • Error level logs are saved under project_root/logs/custom_logs.log (ignored).

Console logs: image

Log file: image

yubinkarki avatar Apr 21 '24 03:04 yubinkarki

I have added the mentioned changes. Please review @horrormyth.

yubinkarki avatar Apr 21 '24 04:04 yubinkarki