Skip to content

Commit 9027436

Browse files
authored
Merge pull request #3 from jaygel179/update-readme
Fix installation process and move testing to dev docs
2 parents c6bcfb3 + bd6c03e commit 9027436

File tree

3 files changed

+58
-1
lines changed

3 files changed

+58
-1
lines changed

README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ Stackify API for Python
22
=======================
33

44
## Installation
5+
stackify-python can be installed through pip:
6+
```bash
7+
$ pip install -U stackify-api-python
8+
```
59

610
**stackify-python-api** can be installed through pip:
711
```bash
@@ -75,3 +79,45 @@ import stackify
7579

7680
logger = stackify.getLogger(basic_config=False)
7781
```
82+
83+
## Django Logging Integration
84+
85+
You can also use your existing django logging and just append stackify logging handler
86+
87+
```python
88+
LOGGING = {
89+
'version': 1,
90+
'disable_existing_loggers': False,
91+
'handlers': {
92+
'file': {
93+
'level': 'DEBUG',
94+
'class': 'logging.FileHandler',
95+
'filename': 'debug.log',
96+
},
97+
'stackify': {
98+
'level': 'DEBUG',
99+
'class': 'stackify.StackifyHandler',
100+
'application': 'MyApp',
101+
'environment': 'Dev',
102+
'api_key': '******',
103+
}
104+
},
105+
'loggers': {
106+
'django': {
107+
'handlers': ['file', 'stackify'],
108+
'level': 'DEBUG',
109+
'propagate': True,
110+
},
111+
},
112+
}
113+
```
114+
115+
Usage
116+
```python
117+
import logging
118+
119+
logger = logging.getLogger('django')
120+
121+
122+
logger.warning('Something happened')
123+
```

docs/Developer.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
## Testing
2+
Run the test suite with setuptools:
3+
```bash
4+
$ ./setup.py test
5+
```
6+
7+
You can obtain a coverage report with nose:
8+
```bash
9+
$ ./setup nosetests --with-coverage --cover-package=stackify
10+
```
11+
You might need to install the `nose` and `coverage` packages.

stackify/log.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def from_record(self, record):
3737
if k not in RECORD_VARS}
3838

3939
if data:
40-
self.data = json.dumps(data, default=lambda x: x.__dict__)
40+
self.data = json.dumps(data, default=lambda x: hasattr(x, '__dict__') and x.__dict__ or x.__str__())
4141

4242
if record.exc_info:
4343
self.Ex = StackifyError()

0 commit comments

Comments
 (0)