More logging when --debug is used

This commit is contained in:
Sean Whalen
2018-10-09 11:48:31 -04:00
parent 7d2949d6a7
commit fd2d5093a9
3 changed files with 12 additions and 0 deletions
+1
View File
@@ -1587,6 +1587,7 @@ def email_results(results, host, mail_from, mail_to, port=0,
message: Override the default plain text body
ssl_context: SSL context options
"""
logging.debug("Emailing report to: {0}".format(",".join(mail_to)))
date_string = datetime.now().strftime("%Y-%m-%d")
if attachment_filename:
if not attachment_filename.lower().endswith(".zip"):
+7
View File
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
import logging
from collections import OrderedDict
import parsedmarc
@@ -7,6 +8,9 @@ from elasticsearch_dsl.search import Q
from elasticsearch_dsl import connections, Object, Document, Index, Nested, \
InnerDoc, Integer, Text, Boolean, DateRange, Ip, Date
logger = logging.getLogger(__name__)
logger.setLevel(logging.WARNING)
class _PolicyOverride(InnerDoc):
type = Text()
@@ -179,6 +183,7 @@ def create_indexes(names=None, settings=None):
settings (dict): Index settings
"""
logger.debug("Creating elasticsearch indexes")
if names is None:
names = ["dmarc_aggregate", "dmarc_forensic"]
for name in names:
@@ -201,6 +206,7 @@ def save_aggregate_report_to_elasticsearch(aggregate_report,
Raises:
AlreadySaved
"""
logger.debug("Saving aggregate report to Elasticsearch")
aggregate_report = aggregate_report.copy()
metadata = aggregate_report["report_metadata"]
org_name = metadata["org_name"]
@@ -299,6 +305,7 @@ def save_forensic_report_to_elasticsearch(forensic_report,
AlreadySaved
"""
logger.debug("Saving forensic report to Elasticsearch")
forensic_report = forensic_report.copy()
sample_date = forensic_report["parsed_sample"]["date"]
sample_date = parsedmarc.human_timestamp_to_datetime(sample_date)
+4
View File
@@ -1,3 +1,4 @@
import logging
from urllib.parse import urlparse
import socket
import json
@@ -9,6 +10,9 @@ from parsedmarc import __version__, human_timestamp_to_timestamp
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
logger = logging.getLogger(__name__)
logger.setLevel(logging.WARNING)
class SplunkError(RuntimeError):
"""Raised when a Splunk API error occurs"""