-
Notifications
You must be signed in to change notification settings - Fork 0
ioana.circu - logging #4
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
bf4dd9d
added logger
2bfc093
option to not log to console
b6bdc8a
setting up logger in separate file
ce0d1e2
updated to use logger object from logger file
777576e
updated .gitignore to include build directory
5e9f851
updated syntax for getting content from dirconfig file
6057ab9
corrected mistake - filename for dirconfig
623b29b
removed unnecessary "debug" keyword in logger
4550a2b
added author to logger.py
3c826d9
Merge branch 'main' into origin/ioana.circu-logging
lr154lrose File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,4 @@ settings.json | |
local/ | ||
localcache/ | ||
*pyc | ||
build/ | ||
build/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
# Directory containing new flights to be pushed to Elasticsearch | ||
/home/badc/software/datasets/flight-finder/add_records/ | ||
/home/users/icircu/flight-pipeline/add/ | ||
# Directory for moving written flights - write DELETE to remove pushed flight records from the local system after pushing. | ||
/home/badc/software/datasets/flight-finder/stac-flightfinder-items/ | ||
/home/users/icircu/test-flights/ | ||
# Logging File | ||
/home/users/icircu/test-flights/logging |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import logging | ||
|
||
def setup_logging(enable_logging=True, console_logging=True): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adding this comment here but it can apply in many places. Consider using type hints for the parameters of functions. In this case If multiple variable types are acceptable, you can use the following:
|
||
""" | ||
Sets up logging configuration. If `enable_logging` is False, no logging will occur. | ||
|
||
:param enable_logging: Flag to enable/disable logging. | ||
""" | ||
file = "dirconfig" | ||
|
||
with open(file) as f: # 'r' is default if not specified. | ||
content = [r.strip() for r in f.readlines()] # Removes the '\n' from all lines | ||
|
||
log_file = content[5].replace('\n','') | ||
|
||
if log_file == '': | ||
print("Error: Please fill in the third directory in dirconfig file") | ||
|
||
handlers = [ | ||
logging.FileHandler(log_file), # Write output to file | ||
] | ||
|
||
if console_logging: | ||
handlers.append(logging.StreamHandler()) # Logs to the console if enabled | ||
|
||
|
||
if enable_logging: | ||
logging.basicConfig( | ||
level=logging.DEBUG, # Capture all levels | ||
format='%(asctime)s - %(levelname)s - %(message)s', | ||
handlers=handlers | ||
) | ||
else: | ||
# Disable logging by setting a null handler | ||
logging.basicConfig(level=logging.CRITICAL) | ||
#NOTSET for no alerts at all | ||
|
||
|
||
enable_logging = True | ||
|
||
# Set up logging with a flag (True to enable logging, False to disable logging) | ||
setup_logging(enable_logging) # Change to False to disable logging | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
|
||
__author__ = "Ioana Circu" | ||
__contact__ = "[email protected]" | ||
__copyright__ = "Copyright 2025 United Kingdom Research and Innovation" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't need the
Debug:
part of the string if your log message already adds this.