This repository has been archived by the owner on Sep 4, 2024. It is now read-only.
-
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.
- Loading branch information
Showing
5 changed files
with
88 additions
and
3 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
Binary file not shown.
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 @@ | ||
"""lmtest notifications package.""" |
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,26 @@ | ||
"""Module containing methods for producing notifications via standard out.""" | ||
|
||
|
||
# ..................................................................................... | ||
class ConsoleNotifier: | ||
"""Emit notifications to the console.""" | ||
|
||
# ........................... | ||
@staticmethod | ||
def notify_failure(message): | ||
"""Emit a notification of failure. | ||
Args: | ||
message (str): A notification message to emit. | ||
""" | ||
print(message) | ||
|
||
# ........................... | ||
@staticmethod | ||
def notify_warning(message): | ||
"""Emit a notification of warning. | ||
Args: | ||
message (str): A notification message to emit. | ||
""" | ||
print(message) |
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,36 @@ | ||
"""Module containing methods for producing notifications via a logger.""" | ||
import logging | ||
from logging .handlers import RotatingFileHandler | ||
import os | ||
|
||
|
||
# ..................................................................................... | ||
class LogNotifier: | ||
"""Emit notifications to a log.""" | ||
# ........................... | ||
def __init__(self, log_filename): | ||
"""Construct a file-based logger. | ||
Args: | ||
log_filename (str): File location to send notifications to. | ||
""" | ||
self.logger = logging.getLogger(os.path.basename(log_filename)) | ||
self.logger.addHandler(RotatingFileHandler(log_filename)) | ||
|
||
# ........................... | ||
def notify_failure(self, message): | ||
"""Emit a notification of failure. | ||
Args: | ||
message (str): A notification message to emit. | ||
""" | ||
self.logger.error(message) | ||
|
||
# ........................... | ||
def notify_warning(self, message): | ||
"""Emit a notification of warning. | ||
Args: | ||
message (str): A notification message to emit. | ||
""" | ||
self.logger.warning(message) |