File tree Expand file tree Collapse file tree 3 files changed +58
-1
lines changed Expand file tree Collapse file tree 3 files changed +58
-1
lines changed Original file line number Diff line number Diff 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
7680logger = 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+ ```
Original file line number Diff line number Diff line change 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.
Original file line number Diff line number Diff 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 ()
You can’t perform that action at this time.
0 commit comments