Skip to content

Commit

Permalink
Add basic logging
Browse files Browse the repository at this point in the history
  • Loading branch information
drewburr committed May 25, 2024
1 parent 5cf21d2 commit de9d4b2
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@

import os
import time
import logging
from prometheus_client import start_http_server, Gauge, Counter, Enum
import requests
import xml.etree.ElementTree as ET
from xml.etree.ElementTree import Element

logging.basicConfig(format='%(asctime)s %(levelname)s: %(message)s', datefmt='%m/%d/%Y %I:%M:%S %p', level=logging.INFO)

# pdu_


Expand All @@ -20,6 +23,9 @@ def __init__(self, address, port, polling_interval_seconds):
self.address = address
self.port = port
self.polling_interval_seconds = polling_interval_seconds
self.logger = logging.getLogger(__name__)



self.device_labels = ["id", "type"]
self.outlet_labels = ["name", "num", "url"]
Expand Down Expand Up @@ -82,7 +88,10 @@ def start_export_loop(self):
"""Metrics fetching loop"""

while True:
start = time.time()
self.process()
end = time.time()
self.logger.info(f'Process completed in {end-start:.2f}s')
time.sleep(self.polling_interval_seconds)

def process(self):
Expand Down

0 comments on commit de9d4b2

Please sign in to comment.