diff --git a/README.md b/README.md index 1fe847b..231158e 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,10 @@ Stackify API for Python ======================= ## Installation +stackify-python can be installed through pip: +```bash +$ pip install -U stackify-api-python +``` **stackify-python-api** can be installed through pip: ```bash @@ -75,3 +79,45 @@ import stackify logger = stackify.getLogger(basic_config=False) ``` + +## Django Logging Integration + +You can also use your existing django logging and just append stackify logging handler + +```python +LOGGING = { + 'version': 1, + 'disable_existing_loggers': False, + 'handlers': { + 'file': { + 'level': 'DEBUG', + 'class': 'logging.FileHandler', + 'filename': 'debug.log', + }, + 'stackify': { + 'level': 'DEBUG', + 'class': 'stackify.StackifyHandler', + 'application': 'MyApp', + 'environment': 'Dev', + 'api_key': '******', + } + }, + 'loggers': { + 'django': { + 'handlers': ['file', 'stackify'], + 'level': 'DEBUG', + 'propagate': True, + }, + }, +} +``` + +Usage +```python +import logging + +logger = logging.getLogger('django') + + +logger.warning('Something happened') +``` diff --git a/docs/Developer.md b/docs/Developer.md new file mode 100644 index 0000000..cbc6905 --- /dev/null +++ b/docs/Developer.md @@ -0,0 +1,11 @@ +## Testing +Run the test suite with setuptools: +```bash +$ ./setup.py test +``` + +You can obtain a coverage report with nose: +```bash +$ ./setup nosetests --with-coverage --cover-package=stackify +``` +You might need to install the `nose` and `coverage` packages. diff --git a/stackify/log.py b/stackify/log.py index 21e2e0b..56c3f0e 100644 --- a/stackify/log.py +++ b/stackify/log.py @@ -37,7 +37,7 @@ def from_record(self, record): if k not in RECORD_VARS} if data: - self.data = json.dumps(data, default=lambda x: x.__dict__) + self.data = json.dumps(data, default=lambda x: hasattr(x, '__dict__') and x.__dict__ or x.__str__()) if record.exc_info: self.Ex = StackifyError()