-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
59 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
web: gunicorn nofussbm:app -w 3 -b "0.0.0.0:$PORT" | ||
web: gunicorn nofussbm:app --logger-class nofussbm.logger.Logger --access-logfile=/dev/null --error-logfile=- -w 3 -b "0.0.0.0:$PORT" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from logging import INFO | ||
from os import environ as ENV | ||
from urlparse import urlparse | ||
|
||
from log4mongo.handlers import MongoHandler, MongoFormatter | ||
|
||
import gunicorn.glogging | ||
|
||
|
||
MONGOLAB = urlparse( ENV[ 'MONGOLAB_URI' ] ) | ||
|
||
|
||
class Logger( gunicorn.glogging.Logger ): | ||
def __init__( self, cfg ): | ||
super( Logger, self ).__init__( cfg ) | ||
access_handler = MongoHandler( level = INFO, host = MONGOLAB.hostname, port = MONGOLAB.port, database_name = MONGOLAB.path[ 1: ], collection = 'access-logs', username = MONGOLAB.username, password = MONGOLAB.password ) | ||
error_handler = MongoHandler( level = INFO, host = MONGOLAB.hostname, port = MONGOLAB.port, database_name = MONGOLAB.path[ 1: ], collection = 'error-logs', username = MONGOLAB.username, password = MONGOLAB.password ) | ||
access_handler.setFormatter( MongoFormatter() ) | ||
error_handler.setFormatter( MongoFormatter() ) | ||
self.access_log.addHandler( access_handler ) | ||
self.access_log.setLevel( INFO ) | ||
self.error_log.addHandler( error_handler ) | ||
self.error_log.setLevel( INFO ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
Flask==0.8 | ||
gunicorn==0.13.4 | ||
pymongo==2.0.1 | ||
Flask | ||
gunicorn | ||
pymongo | ||
log4mongo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
#!/bin/bash | ||
|
||
heroku config --app nofussbm-old -s | egrep '(MONGOLAB_URI|SECRET_KEY|SENDGRID_PASSWORD|SENDGRID_USERNAME)' > .env | ||
heroku config --app nofussbm -s | egrep '(MONGOLAB_URI|SECRET_KEY|SENDGRID_PASSWORD|SENDGRID_USERNAME)' > .env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/usr/bin/env python | ||
|
||
from os import environ as ENV | ||
from urlparse import urlparse | ||
|
||
from pymongo import Connection | ||
|
||
|
||
MONGOLAB_URI = ENV[ 'MONGOLAB_URI' ] | ||
|
||
|
||
conn = Connection( MONGOLAB_URI ) | ||
db = conn[ urlparse( MONGOLAB_URI ).path[ 1: ] ] | ||
|
||
print 'ACCESS\n' + 80 * '-' | ||
for entry in db[ 'access-logs' ].find(): | ||
print entry['timestamp'].as_datetime(), entry['level'], entry['loggerName'], entry['message'] | ||
print 'ERROR\n' + 80 * '-' | ||
for entry in db[ 'error-logs' ].find(): | ||
print entry['timestamp'].as_datetime(), entry['level'], entry['loggerName'], entry['message'] |