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

feat: log to a file #111

Open
techsavvyash opened this issue May 24, 2023 · 3 comments
Open

feat: log to a file #111

techsavvyash opened this issue May 24, 2023 · 3 comments
Labels
good first issue Good for newcomers

Comments

@techsavvyash
Copy link
Collaborator

techsavvyash commented May 24, 2023

Description

cQube generates lots of logs, during the ingestion process. A utility function to allow logging all the log data to a file needs to be implemented.

@techsavvyash techsavvyash added the good first issue Good for newcomers label May 24, 2023
@shubhrai2811
Copy link

shubhrai2811 commented May 31, 2023

log_util.zip

Here I have used Python's built-in logging module to create a logger function.
This utility function, setup_logger, takes two arguments: log_file_name and an optional log_level. It creates a directory called logs if it doesn't exist, and then sets up a logger with the specified log level and file name.
you can use this utility function in your other Python files to log messages to a file. example-

from log_util import setup_logger

logger = setup_logger('cQube.log')

logger.info('This is an info message')
logger.warning('This is a warning message')
logger.error('This is an error message')

This will create a log file called cQube.log in the logs directory and log the messages with their respective log levels.

STEPS to Use this Logger-

  1. Extract the Zip file and copy the log_util.py to the main project folder
  2. Then you can include the logger in other Python files similarly to the example shown above
  • This is my first time trying to contribute to a project. Please let me know the feedback and If you want anything to be changed.

Thanks
Shubh Rai

@techsavvyash
Copy link
Collaborator Author

Hey @shubhrai2811,
Thanks for showing interest and building this logger.
Can you try implementing this as a typescript function in this project itself and contribute that code via a PR.
Thanks

@Bigguysahaj
Copy link

@techsavvyash can you go through this PR i created and see if this is what you wanted

#129

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants