-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Folder Handling and Logging Enhancements (#12)
#### Overview This PR introduces folder structure support in the `generate` and `validate` commands, along with improved logging functionality using `colorlog` for better debugging and runtime insights. #### Changes - **Folder Structure Support**: - The `generate.py` script now supports creating folder structures from YAML definitions. - Added validation for the folder structure in `validate.py`, ensuring folders are correctly defined and contain a valid `struct` key. - **Logging Enhancements**: - New logging configuration file `logging_config.py` introduced, integrating `colorlog` for color-coded log output. - Refactored log levels in various parts of the code, changing some `info` logs to `debug` where appropriate for better verbosity control. - **Dependency Update**: - Added `colorlog` to `requirements.txt` to support colored logging. #### Justification The ability to define folder structures in YAML is critical for handling more complex project setups, especially for projects relying on modular directory layouts. Enhanced logging is essential for improving the traceability and debuggability of the tool's operations. #### Impact - Teams will now be able to define and validate folder structures more easily within the configuration files. - Logging improvements will make debugging easier and more informative, particularly during dry runs and when setting up folder hierarchies. - The addition of `colorlog` may require updating environments to include the new dependency.
- Loading branch information
Showing
6 changed files
with
95 additions
and
7 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -5,3 +5,4 @@ python-dotenv | |
jinja2 | ||
PyGithub | ||
argcomplete | ||
colorlog |
This file contains 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 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 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 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,31 @@ | ||
# FILE: struct_module/logging_config.py | ||
import logging | ||
import colorlog | ||
|
||
def configure_logging(level=logging.INFO, log_file=None): | ||
"""Configure logging with colorlog.""" | ||
handler = colorlog.StreamHandler() | ||
handler.setFormatter(colorlog.ColoredFormatter( | ||
"%(log_color)s[%(asctime)s][%(levelname)s][struct] >>> %(message)s", | ||
datefmt='%Y-%m-%d %H:%M:%S', | ||
log_colors={ | ||
'DEBUG': 'cyan', | ||
'INFO': 'green', | ||
'WARNING': 'yellow', | ||
'ERROR': 'red', | ||
'CRITICAL': 'bold_red', | ||
} | ||
)) | ||
|
||
logging.basicConfig( | ||
level=level, | ||
handlers=[handler], | ||
) | ||
|
||
if log_file: | ||
file_handler = logging.FileHandler(log_file) | ||
file_handler.setFormatter(logging.Formatter( | ||
"[%(asctime)s][%(levelname)s][struct] >>> %(message)s", | ||
datefmt='%Y-%m-%d %H:%M:%S' | ||
)) | ||
logging.getLogger().addHandler(file_handler) |
This file contains 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