Skip to content

Commit

Permalink
Merge pull request #21 from guydavis/dev
Browse files Browse the repository at this point in the history
Fixes for Chiadog over-notifications
guydavis authored Nov 1, 2022
2 parents c6075f3 + 614c2e0 commit 811ba16
Showing 7 changed files with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -24,7 +24,8 @@ def __init__(self):

def check(self, obj: HarvesterActivityMessage) -> Optional[Event]:
event = None
if obj.total_plots_count > self._max_farmed_plots:
# Only alert if going from 1 or more plots to more. Don't spam a message from zero on every startup...
if self._max_farmed_plots > 0 and obj.total_plots_count > self._max_farmed_plots:
logging.info(f"Detected new plots. Farming with {obj.total_plots_count} plots.")
message = (
f"Connected HDD? The total plot count increased from "
11 changes: 7 additions & 4 deletions src/chia_log/log_consumer.py
Original file line number Diff line number Diff line change
@@ -69,6 +69,10 @@ def __init__(self, log_path: Path, coin_name: str, coin_symbol: str, prefix: str
logging.info(f"Enabled local file log consumer: {self._expanded_log_path}")
self._offset_path = mkdtemp() / Config.get_log_offset_path()
logging.info(f"Using temporary directory {self._offset_path}")
# Cleanup stale temporary file
if self._offset_path.exists():
logging.info(f"Deleting stale log offset file: {self._offset_path}")
self._offset_path.unlink()
self._is_running = True
self._thread = Thread(target=self._consume_loop)
self._thread.start()
@@ -78,11 +82,10 @@ def __init__(self, log_path: Path, coin_name: str, coin_symbol: str, prefix: str
def stop(self):
logging.info("Stopping")

# Why were original authors throwing away the offset file on every stop?
# Cleanup the temporary file
#if self._offset_path.exists():
# logging.info(f"Deleting {self._offset_path}")
# self._offset_path.unlink()
if self._offset_path.exists():
logging.info(f"Deleting {self._offset_path}")
self._offset_path.unlink()

self._is_running = False

2 changes: 1 addition & 1 deletion src/chia_log/parsers/block_parser.py
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@ class BlockParser:
def __init__(self, config: Optional[dict] = None):
logging.info("Enabled parser for block found stats.")
self._regex = re.compile(
r"([0-9:.]*) full_node (?:src|" + config['prefix'] + ").full_node.full_node\s*: INFO\s* ((?:🍀 |.)\s*Farmed unfinished_block)"
r"([0-9:.T-]*) full_node (?:src|" + config['prefix'] + ").full_node.full_node\s*: INFO\s* ((?:🍀 |.)\s*Farmed unfinished_block)"
)

def parse(self, logs: str) -> List[BlockMessage]:
2 changes: 1 addition & 1 deletion src/chia_log/parsers/finished_signage_point_parser.py
Original file line number Diff line number Diff line change
@@ -29,7 +29,7 @@ def __init__(self, config: Optional[dict] = None):
# Doing some "smart" tricks with this expression to also match the 64th signage point
# with the same regex expression. See test examples to see how they differ.
self._regex = re.compile(
r"([0-9:.]*) full_node (?:src|" + config['prefix'] + ").full_node.full_node(?:\s?): INFO\s*(?:⏲️|.)[a-z A-Z,]* ([0-9]*)\/64"
r"([0-9:.T-]*) full_node (?:src|" + config['prefix'] + ").full_node.full_node(?:\s?): INFO\s*(?:⏲️|.)[a-z A-Z,]* ([0-9]*)\/64"
)

def parse(self, logs: str) -> List[FinishedSignagePointMessage]:
2 changes: 1 addition & 1 deletion src/chia_log/parsers/harvester_activity_parser.py
Original file line number Diff line number Diff line change
@@ -31,7 +31,7 @@ class HarvesterActivityParser:
def __init__(self, config: Optional[dict] = None):
logging.info("Enabled parser for harvester activity - eligible plot events.")
self._regex = re.compile(
r"([0-9:.]*) harvester (?:src|" + config['prefix'] + ").harvester.harvester(?:\s?): INFO\s*([0-9]+) plots were "
r"([0-9:.T-]*) harvester (?:src|" + config['prefix'] + ").harvester.harvester(?:\s?): INFO\s*([0-9]+) plots were "
r"eligible for farming ([0-9a-z.]*) Found ([0-9]) proofs. Time: ([0-9.]*) s. "
r"Total ([0-9]*) plots"
)
2 changes: 1 addition & 1 deletion src/chia_log/parsers/partial_parser.py
Original file line number Diff line number Diff line change
@@ -26,7 +26,7 @@ class PartialParser:

def __init__(self, config: Optional[dict] = None):
logging.info("Enabled parser for partial submitting stats.")
self._regex = re.compile(r"([0-9:.]*) farmer (?:src|" + config['prefix'] + ").farmer.farmer\s*: INFO\s* (Submitting partial)")
self._regex = re.compile(r"([0-9:.T-]*) farmer (?:src|" + config['prefix'] + ").farmer.farmer\s*: INFO\s* (Submitting partial)")

def parse(self, logs: str) -> List[PartialMessage]:
"""Parses all farmer activity messages from a bunch of logs
2 changes: 1 addition & 1 deletion src/chia_log/parsers/wallet_added_coin_parser.py
Original file line number Diff line number Diff line change
@@ -26,7 +26,7 @@ def __init__(self, config: Optional[dict] = None):
logging.info("Enabled parser for wallet activity - added coins.")
self._prefix = config['prefix']
self._regex = re.compile(
r"([0-9:.]*) wallet (?:src|" + self._prefix + ").wallet.wallet_state_manager(?:\s?): "
r"([0-9:.T-]*) wallet (?:src|" + self._prefix + ").wallet.wallet_state_manager(?:\s?): "
r"INFO\s*Adding.*coin:.*'?amount'?: ([0-9]*)"
)

0 comments on commit 811ba16

Please sign in to comment.