robcarver17 / pysystemtrade

Systematic Trading in python
GNU General Public License v3.0
2.66k stars 837 forks source link

Python logging switch #1305

Closed bug-or-feature closed 10 months ago

bug-or-feature commented 11 months ago

This PR refactors away the last few usages of log.setup(). This one handles the more complex cases, where logger instances were passed around as function parameters. The solution in most cases is to refactor existing functions into class methods, where the logger instance can be accessed as a class variable instead. The changes fall into three groups:

Uses of log.setup() and specific_log() in FX and price code

Uses of log_with_attributes() in the algo code

Uses of log_with_attributes() in the order and stack handler code

robcarver17 commented 11 months ago

Will look at this in January as a bit of a big one

bug-or-feature commented 10 months ago

@robcarver17 awesome. there'll be one more PR to remove the unused functions, fix tests, update docs and tidy up

robcarver17 commented 10 months ago

Now I have this error:

  File "/home/rob/pysystemtrade/sysdata/parquet/parquet_futures_per_contract_prices.py", line 89, in _write_prices_at_frequency_for_contract_object_no_checking
    log = futures_contract_object.log(self.log)
AttributeError: 'futuresContract' object has no attribute 'log'

I'm guessing this is a merge issue between droparctic and develop. But what is the correct way of rewriting this in new log world:

        log = futures_contract_object.log(self.log)

I haven't been following closely enough clearly, but did you drop the new_log = object.log(existing_log) pattern?

bug-or-feature commented 10 months ago

I just created a new PR for the final tidy up, I'll fix that issue in there

robcarver17 commented 10 months ago

OK I've hotfixed it but not sure if it's the correct way of doing it.

bug-or-feature commented 10 months ago

I've pushed a fix

robcarver17 commented 10 months ago

Thanks mate