diff --git a/DataWriter.py b/DataWriter.py
index f14a5b6..44f4f11 100644
--- a/DataWriter.py
+++ b/DataWriter.py
@@ -1,5 +1,6 @@
 import json
 import os
+import logging
 
 
 class DataWriter:
@@ -24,10 +25,22 @@ class DataWriter:
                 relevant output parameters to be written to the JSON file.
         """
 
-        self.metrics = self.convert_np_arrays(hrm.output_dict)
-        self.csv_file = hrm.csv_file
-        output_file = self.get_output_file_name(self.csv_file)
-        self.write_to_json(self.metrics, output_file)
+        logging.basicConfig(filename="DataWriter_logs.txt",
+                            format='%(asctime)s %(levelname)s:%(message)s',
+                            datefmt='%m/%d/%Y %I:%M:%S %p')
+
+        if hrm.isValid:
+            self.metrics = self.convert_np_arrays(hrm.output_dict)
+            self.csv_file = hrm.csv_file
+            output_file = self.get_output_file_name(self.csv_file)
+            self.write_to_json(self.metrics, output_file)
+
+        else:
+            print("Error: Data is too noisy for heart rate calculation. "
+                  "These data will not be written to a JSON file.")
+            logging.error("Data from " + hrm.csv_file + " is too noisy. JSON "
+                                                        "file will not be "
+                                                        "written.")
 
     def get_output_file_name(self, csv_file):
         """Finds the root file name (i.e. the file name without the .csv
diff --git a/HRM_Driver.py b/HRM_Driver.py
index e276491..4c5dc77 100644
--- a/HRM_Driver.py
+++ b/HRM_Driver.py
@@ -1,3 +1,4 @@
+import logging
 from DataReader import DataReader
 from DataWriter import DataWriter
 from HRM_Processor import HRM_Processor
diff --git a/HRM_Processor.py b/HRM_Processor.py
index a4db441..f704d6c 100644
--- a/HRM_Processor.py
+++ b/HRM_Processor.py
@@ -44,13 +44,11 @@ class HRM_Processor:
         try:
             self.validate_outputs(self.output_dict)
         except ValueError:
-            print("The heart rate monitor has calculated a heart rate that "
-                  "is not physiologically realistic. This is likely due to "
-                  "a high level of signal noise. These misleading / "
-                  "inaccurate outputs will not be written to a JSON file.")
-            logging.error("Invalid BPM calculated from ECG strip. isValid "
-                          "flag set to false preventing this misleading data "
-                          "from being written to a JSON file.")
+            print("Warning: The heart rate monitor has calculated a heart "
+                  "rate that is not physiologically realistic.")
+            logging.warning("Invalid BPM calculated from ECG strip. isValid "
+                            "flag set to false preventing this misleading "
+                            "data from being written to a JSON file.")
             self.isValid = False
 
     def write_outputs_to_dict(self):

The DataWriter should not write if the ECG data from the HRM_Processor is not valid 
The HRM_Processor now has a parameter, isValid, which specifies whether or not the number of beats is physiologically realistic. The DataWriter should use this parameter to decide whether or not it should actually write the data. 
diff --git a/test_DataWriter.py b/test_DataWriter.py
index ade7caf..2d8f313 100644
--- a/test_DataWriter.py
+++ b/test_DataWriter.py
@@ -6,7 +6,7 @@ from HRM_Processor import HRM_Processor
 from DataWriter import DataWriter
 
 
-def test_DataWriter_init(hrm):
+def test_DataWriter_init_valid_case(hrm):
     """Tests the initialization of the DataWriter object, and that it
     successfully gets the output_dict from the input_dict and stores it as
     metrics.
@@ -21,10 +21,35 @@ def test_DataWriter_init(hrm):
     None
 
     """
+    hrm.isValid = True  # Force validity for testing case
     dw = DataWriter(hrm)
     assert dw.metrics == hrm.output_dict
 
 
+def test_DataWriter_init_invalid_case(hrm, capsys):
+    """Tests the initialization of the DataWriter object for a case where
+    the data from the HRM_Processor object is not valid.
+
+    Parameters
+    ----------
+    hrm:    HRM_Processor
+            Generic HRM_Processor made from a DataReader with test_file.csv
+    capsys: Pytest fixture
+            A decorator for getting outputs printed to the console
+    Returns
+    -------
+    None
+
+    """
+    hrm.isValid = False  # Force invalidity for testing case
+    dw = DataWriter(hrm)
+    captured_output, err = capsys.readouterr()
+
+    assert captured_output == "Error: Data is too noisy for heart rate " \
+                              "calculation. These data will not be written " \
+                              "to a JSON file.\n"
+
+
 def test_DataWriter_init_write_to_dict():
     """Tests that the construction of a DataWriter object creates a .json
     file with the base file name that is the same as the file name of the

pip install -r requirements.txt
parse_log_pytest
requirements.txt
pytest
3.9
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
coverage==7.8.0
exceptiongroup==1.2.2
execnet==2.1.1
iniconfig==2.1.0
numpy==2.0.2
packaging==24.2
pep8==1.7.1
pluggy==1.5.0
pytest==8.3.5
pytest-cache==1.0
pytest-cov==6.0.0
pytest-pep8==1.0.6
scipy==1.13.1
tomli==2.2.1

name: bme590hrm
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=3.0.16=h5eee18b_0
  - pip=25.0=py39h06a4308_0
  - python=3.9.21=he870216_1
  - readline=8.2=h5eee18b_0
  - setuptools=75.8.0=py39h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - tzdata=2025a=h04d1e81_0
  - wheel=0.45.1=py39h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - coverage==7.8.0
      - exceptiongroup==1.2.2
      - execnet==2.1.1
      - iniconfig==2.1.0
      - numpy==2.0.2
      - packaging==24.2
      - pep8==1.7.1
      - pluggy==1.5.0
      - pytest==8.3.5
      - pytest-cache==1.0
      - pytest-cov==6.0.0
      - pytest-pep8==1.0.6
      - scipy==1.13.1
      - tomli==2.2.1
prefix: /opt/conda/envs/bme590hrm

test_DataWriter.py::test_DataWriter_init_invalid_case
test_DataWriter.py::test_DataWriter_init_valid_case test_DataWriter.py::test_DataWriter_init_write_to_dict test_DataWriter.py::test_write_to_json test_DataWriter.py::test_convert_np_arrays
HRM_Processor.py DataWriter.py HRM_Driver.py
HRM_Processor.py DataWriter.py HRM_Driver.py