Skip to content

Commit

Permalink
Feature internal 46 logging (#400)
Browse files Browse the repository at this point in the history
* Adding logging framework for STIGS

* Made changes to the test yaml files for agg_stat

* Syntax edit

* Needed indentation

* Synatx edits to agg_stat

* Chnaged import statement

* Changed import statement

* Needed a line of code to be added

* Added logging statements and modified tests accordingly

* Syntax edit to logger variable as a function argument

* Syntax edits

* Syntax edits based on pytest outputs

* Changes to safe_log function

* Positional argument changes for logger

* Syntax edits

* Edit to a function call

* Added logger to test_event_equalize

* Changed placement of logger argument

* Edits to placement of logger argument

* Logging added to utils and metcalcpy by using safe_log in util

* Syntax edits

* Syntax edits wrt ValueError

* Syntax edits to NameError

* Minor syntax edits

* Minor syntax edits

* Minor edits with safe_log

* Minor edits to safe_log in agg_eclv

* Minor edit to event_equalize in utils

* Syntax edits to safe_log

* Syntax edits

* Added missing bracket

* New syntax edits

* Edits to Aplin

* Final edit to agg_stat

* Edits based on SonarQube findings

* adding new logging directions

* first page of google doc added

* fixing indenting and code block to python

* Removed extra debug statements

* Update actions/upload-artifact@v2 to be actions/upload-artifact@v4

* adding second page of documentation

* adding spacing for better presentation

* Trying to fix Enumerated list ends without a blank line warning

* fixing typo

---------

Co-authored-by: Ishita Srivastava <[email protected]>
Co-authored-by: Lisa Goodrich <[email protected]>
Co-authored-by: lisagoodrich <[email protected]>
Co-authored-by: Julie Prestopnik <[email protected]>
  • Loading branch information
5 people authored Oct 2, 2024
1 parent e036ece commit 7ae108f
Show file tree
Hide file tree
Showing 57 changed files with 6,643 additions and 2,160 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/documentation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
with:
name: documentation
path: artifact/documentation
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v4
if: failure()
with:
name: documentation_warnings.log
Expand Down
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"IDX.aI.enableInlineCompletion": true,
"IDX.aI.enableCodebaseIndexing": true
}
1 change: 1 addition & 0 deletions docs/Users_Guide/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ National Center for Atmospheric Research (NCAR) is sponsored by NSF.
:numbered: 4

installation
logging
vertical_interpolation
difficulty_index
aggregation
Expand Down
112 changes: 112 additions & 0 deletions docs/Users_Guide/logging.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
****************
Logging In Guide
****************


This guide provides a comprehensive overview of the newly integrated logging capabilities
within METcalcpy. These enhancements are designed to provide users with valuable insights
into the application's execution, aiding in tasks such as debugging, performance monitoring,
and understanding the operational flow of the program.


What's New
==========

Centralized Logging Configuration (**logging_config.py**):
----------------------------------------------------------

A new script, **logging_config.py**, has been introduced to centralize the management of logging
configurations. This approach ensures consistency and simplifies the maintenance of logging
settings across all modules within METcalcpy.


* Key Feature: :code:`setup_logging` function

* The :code:`setup_logging` function is the core of **logging_config.py**. It initializes
and configures the logger instance based on parameters specified in a YAML configuration
file. This function reads logging settings such as :code:`log_dir`,
:code:`log_filename`, and :code:`log_level` from the YAML file and sets
up Python's logging module accordingly.
* By isolating the logging configuration in this script, it becomes easier to
manage and update logging behavior without altering the core logic of other modules.

Example Integration in **agg_stat.py**:

.. code-block:: py
from metcalcpy.logging_config import setup_logging
class AggStat:
def __init__(self, in_params):
self.logger = setup_logging(in_params)
# Other initialization code...
In this example, when an :code:`AggStat object` is instantiated, it invokes the
:code:`setup_logging` function, passing in the :code:`in_params` dictionary,
which contains logging configurations from a YAML file such as
**val1l2_agg_stat.yaml**. This ensures the logger is configured according to
the user's settings.

YAML-Driven Configuration
-------------------------

METcalcpy now allows users to customize logging behavior directly within
their YAML configuration files, eliminating the need for hardcoding
logging settings in Python scripts.

**Key Parameters in YAML Configuration:**

:code:`log_dir:` Specifies the directory where log files are stored.

:code:`log_filename:` Defines the name of the log file.

:code:`log_level:` Determines the verbosity of the log output.
Available levels are :code:`DEBUG, INFO, WARNING, and ERROR:`.

:code:`log_level:` By setting the appropriate log level in your YAML configuration
file (e.g., log_level: WARNING), you can control the verbosity of the log output,
ensuring that only the necessary information is recorded.

METcalcpy supports the following log levels:

1. **DEBUG:**

* **Purpose:** Captures detailed information for diagnosing issues.
* **Use Case:** Ideal during development or troubleshooting to see all
the internal workings of the application.

2. **INFO:**

* **Purpose:** Records general information about the application's execution.
* **Use Case:** Suitable for tracking the progress and key events
in the application's workflow without overwhelming detail.

3. **WARNING:**

* **Purpose:** Logs potential issues that are not immediately critical but
could lead to problems.
* **Use Case:** Useful for highlighting areas that may require attention
but don't stop the application from running.

4. **ERROR:**

* **Purpose:** Captures serious issues that prevent parts of the
application from functioning correctly.
* **Use Case:** Necessary for logging events that require immediate
attention and could cause the application to fail or produce incorrect results.

Informative Log Formatting
--------------------------

Log messages in METcalcpy are meticulously formatted to include detailed information,
improving readability and facilitating easier analysis of log data.










Loading

0 comments on commit 7ae108f

Please sign in to comment.