Skip to content

Commit

Permalink
new diag configuration values
Browse files Browse the repository at this point in the history
  • Loading branch information
joamag committed Feb 21, 2018
1 parent d272394 commit 72b11dd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
6 changes: 6 additions & 0 deletions doc/configuration.md
Expand Up @@ -17,6 +17,12 @@ should be changed carefully to avoid unwanted changes (defaults to `current`)
* `ADMIN_OAUTH` (`bool`) - If OAuth 2.0 support should be enabled for the administration interface (defaults to `True`)
* `ADMIN_AVATAR_DEFAULT` (`bool`) - If a new default image should be set for an account's avatar if none is set (defaults to `False`)

### Diag

* `DIAG_STORE` (`bool`) - If the multiple HTTP requests in diagnostics should be store in the data source (defaults to `True`)
* `DIAG_OUTPUT` (`bool`) - If each of the HTTP requests should be printed to the stdout (defaults to `True`)
* `DIAG_FORMAT` (`str`) - The format to be used while outputting the HTTP request (defaults to `combined`)

### CMS

* `CMS_CACHE_ENGINE` (`str`) - The generic name of the cache engine to be used for CMS access (defaults to `memory`)
Expand Down
15 changes: 13 additions & 2 deletions src/appier_extras/parts/diag/part.py
Expand Up @@ -49,6 +49,15 @@ class DiagPart(appier.Part):
that allow more and better debugging of an Application.
"""

def __init__(self, *args, **kwargs):
appier.Part.__init__(self, *args, **kwargs)
self.store = kwargs.get("store", True)
self.output = kwargs.get("output", True)
self.format = kwargs.get("format", "combined")
self.store = appier.conf("DIAG_STORE", self.store, cast = bool)
self.output = appier.conf("DIAG_OUTPUT", self.output, cast = bool)
self.format = appier.conf("DIAG_FORMAT", self.format)

def version(self):
return base.VERSION

Expand All @@ -70,8 +79,10 @@ def before_request(self):
pass

def after_request(self):
print(self._combined_log())
self._store_log()
method = getattr(self, "_%s_log" % self.format)
result = method()
if self.output: print(result)
if self.store: self._store_log()

@appier.ensure(token = "admin.status")
def list_http(self):
Expand Down

0 comments on commit 72b11dd

Please sign in to comment.