tenable / pyTenable

Python Library for interfacing into Tenable's platform APIs
https://pytenable.readthedocs.io
MIT License
354 stars 173 forks source link

Add timestamp to logs #62

Closed nkeuning closed 5 years ago

nkeuning commented 5 years ago

Is your feature request related to a problem? Please describe. It would be very helpful to have the time that a particular log entry happened in the logs.

Describe the solution you'd like Timestamp included with each log message

Describe alternatives you've considered N/A

Additional context Who doesn't like more data in their logs? :)

SteveMcGrath commented 5 years ago

The formatting of the logs is all based on the format you provide to them. For example:

>>> FORMAT = '%(asctime)s %(levelname)s: %(message)s'
>>> import os
>>> import logging
>>> logging.basicConfig(format=FORMAT, level=logging.DEBUG)
>>> from tenable.io import TenableIO
>>> tio = TenableIO(os.getenv('TIO_ACCESS_KEY'), os.getenv('TIO_SECRET_KEY'))
>>> a = tio.exports.assets()
2019-01-22 12:20:41,654 DEBUG: query={}, body={'filters': {}, 'chunk_size': 100}
2019-01-22 12:20:41,663 DEBUG: Starting new HTTPS connection (1): cloud.tenable.com:443
2019-01-22 12:20:41,906 DEBUG: https://cloud.tenable.com:443 "POST /assets/export HTTP/1.1" 200 None
2019-01-22 12:20:41,909 DEBUG: Initiated asset export d32bc3cd-f171-4866-9a34-be4ccece23d4
>>>

Nothing needs to be done on the library to support this, just pass the the logging format you wish to use.