csingley / ofxtools

Python OFX Library
Other
301 stars 68 forks source link

logging.json: how to use? #72

Closed hleofxquotes closed 4 years ago

hleofxquotes commented 4 years ago

Any guidance on how to enable/disable logging? I tried to make a quick change in logging.json to

    "loggers": {
        "": {
            "level": "DEBUG",
            "handlers": [
                "logfile"
            ]
        }
    }

And re-run

$ ofxget prof amex 

Did not any output at all in my ofxtools.log file.

Thanks in advance,

csingley commented 4 years ago

The logging facilities are new & unfinished, but you should get some output. Again, what version of ofxtools are you using? I definitely pushed a couple versions to PyPI that had broken logging.

My current ~/.config/ofxtools/logging.json looks like this:

{
    "version": 1,
    "disable_existing_loggers": false,
    "formatters": {
        "simple": {
            "style": "{",
            "format": "{name} [{levelname}] - {message}"
        },
        "timestamped": {
            "style": "{",
            "format": "{asctime} - {name} [{levelname}] - {message}"
        }
    },
    "handlers": {
        "console": {
            "class": "logging.StreamHandler",
            "stream": "ext://sys.stdout",
            "formatter": "simple"
        },
        "logfile": {
            "class": "logging.FileHandler",
            "filename": "/home/csingley/.cache/ofxtools/log/ofxtools.log",
            "formatter": "timestamped"
        }
    },
    "loggers": {
        "": {
            "level": "WARNING",
            "handlers": [
                "console",
                "logfile"
            ]
        }
    }
}
hleofxquotes commented 4 years ago

I fork and clone the current repo. Still not able to sort out the logging.json usage yet but I've found the --verbose flag and that give the information I am looking for currently:

I am adding a note in case it is useful for other

python ./ofxtools/scripts/ofxget.py  prof amex --verbose --verbose --verbose

will print out the OFX request

...
ofxtools.Client [DEBUG] - Finished request: <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?OFX OFXHEADER="200" VERSION="211" SECURITY="NONE" OLDFILEUID="NONE" NEWFILEUID="6332384b-ff83-44b3-84b9-c476f3840aea"?>
<OFX><SIGNONMSGSRQV1><SONRQ><DTCLIENT>20191107234428.035[0:GMT]</DTCLIENT><USERID>anonymous00000000000000000000000</USERID><USERPASS>anonymous00000000000000000000000</USERPASS><LANGUAGE>ENG</LANGUAGE><FI><ORG>AMEX</ORG><FID>3101</FID></FI><APPID>QWIN</APPID><APPVER>2700</APPVER><CLIENTUID>49fcb73b-7474-4466-b5ca-d782332445c2</CLIENTUID></SONRQ></SIGNONMSGSRQV1><PROFMSGSRQV1><PROFTRNRQ><TRNUID>3e21bddf-9789-487c-9a2e-2f95dd33fbe8</TRNUID><PROFRQ><CLIENTROUTING>NONE</CLIENTROUTING><DTPROFUP>19900101000000.000[0:GMT]</DTPROFUP></PROFRQ></PROFTRNRQ></PROFMSGSRQV1></OFX>