Skip to content

Commit

Permalink
♻️ logger
Browse files Browse the repository at this point in the history
  • Loading branch information
mraniki committed Oct 10, 2023
1 parent 81745c0 commit f644595
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
10 changes: 5 additions & 5 deletions findmyorder/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
# Load the default settings file
settings_files=[
os.path.join(ROOT, "default_settings.toml"),
'talky_settings.toml',
'settings.toml',
'.secrets.toml'
".op.toml",
"talky_settings.toml",
"settings.toml",
".secrets.toml" ".op.toml",
],
# Load the.env file
load_dotenv=True,
# Set the environments to True
environments=True,
# Set the default environment
default_env="default",)
default_env="default",
)
2 changes: 1 addition & 1 deletion findmyorder/default_settings.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ mapping = [

# Instrument to be ignored
# when generating an order
ignore_instrument = "US500 USTEC DOGE"
ignore_instrument = "US500 DOGE"

########################################
### END OF DEFAULT SETTINGS ###
Expand Down
17 changes: 9 additions & 8 deletions findmyorder/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"""
from datetime import datetime

from loguru import logger
from pyparsing import (
Combine,
Optional,
Expand Down Expand Up @@ -65,7 +66,7 @@ async def search(self, my_string: str) -> bool:
"""
if my_string:
string_check = my_string.split()[0].lower()
self.logger.debug("Searching order identifier in {}", string_check)
logger.debug("Searching order identifier in {}", string_check)
if string_check in settings.action_identifier.lower():
return True
return False
Expand Down Expand Up @@ -135,11 +136,11 @@ async def identify_order(
)

order = order_grammar.parse_string(instring=my_string, parse_all=False)
self.logger.debug("Order parsed {}", order)
logger.debug("Order parsed {}", order)
return order.asDict()

except Exception as error:
self.logger.error(error)
logger.error(error)
return error

async def get_order(
Expand All @@ -158,18 +159,18 @@ async def get_order(
"""
if not await self.search(msg):
self.logger.debug("No order identified")
logger.debug("No order identified")
return None
order = await self.identify_order(msg)
if isinstance(order, dict):
order["timestamp"] = datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ")
if settings.instrument_mapping:
self.logger.debug("mapping")
logger.debug("mapping")
await self.replace_instrument(order)
if order["instrument"] in settings.ignore_instrument:
self.logger.debug("Ignoring instrument {}", order["instrument"])
logger.debug("Ignoring instrument {}", order["instrument"])
return
self.logger.debug("Order identified {}", order)
logger.debug("Order identified {}", order)
return order

async def replace_instrument(self, order):
Expand All @@ -188,5 +189,5 @@ async def replace_instrument(self, order):
if item["id"] == instrument:
order["instrument"] = item["alt"]
break
self.logger.debug("Instrument symbol changed", order)
logger.debug("Instrument symbol changed", order)
return order

0 comments on commit f644595

Please sign in to comment.