Skip to content

Commit

Permalink
Replace javascript logging with python logging, close #261.
Browse files Browse the repository at this point in the history
  • Loading branch information
elplatt committed Sep 2, 2016
1 parent bce926b commit f9318ec
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 17 deletions.
3 changes: 3 additions & 0 deletions app.config.sample
Expand Up @@ -16,3 +16,6 @@ num_threads = 0

[analytics]
google_analytics_id =

[sentry]
dsn = https://<key>:<secret>@app.getsentry.com/<project>
21 changes: 8 additions & 13 deletions app/core/__init__.py
Expand Up @@ -12,6 +12,10 @@

import os.path

from raven.conf import setup_logging
from raven.contrib.flask import Sentry
from raven.handlers.logging import SentryHandler

# Load configuration
config = ConfigParser.ConfigParser()
current_dir = os.path.dirname(os.path.abspath(__file__))
Expand All @@ -21,27 +25,18 @@
logger = logging.getLogger(__name__) # the mediameter logger

# setup logging
sentry = Sentry(dsn=config.get('sentry', 'dsn'))
handler = SentryHandler(config.get('sentry', 'dsn'))
setup_logging(handler)
logging.basicConfig(level=logging.INFO)
log_formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
log_handler = logging.handlers.RotatingFileHandler(
os.path.join(base_dir,'log','mediameter.log'), 'a', 10485760, 10) # 10MB
log_handler.setFormatter(log_formatter)
# set up mediacloud logging to the file
mc_logger = logging.getLogger('mediacloud')
mc_logger.propagate = False
mc_logger.addHandler(log_handler)
# set up requests logging to the file
requests_logger = logging.getLogger('requests')
requests_logger.propagate = False
requests_logger.addHandler(log_handler)
# set up mediameter logging the same way
logger.propagate = False
logger.addHandler(log_handler)

logger.info("---------------------------------------------------------------------------------------")

# Flask app
flapp = flask.Flask(__name__)
sentry.init_app(flapp)
flapp.secret_key = 'put secret key here'
assets = Environment(flapp)

Expand Down
4 changes: 0 additions & 4 deletions app/core/core_templates/base.html
Expand Up @@ -167,10 +167,6 @@ <h3><a href="http://cyber.law.harvard.edu"><img class="img-responsive" src="stat
{% endassets %}

{% block scripts %}{% endblock %}
<script src="https://cdn.ravenjs.com/3.4.1/raven.min.js"></script>
<script type="text/javascript">
Raven.config('https://793ffceba9304a6cad3d381c4d0db51b@app.getsentry.com/91699').install();
</script>
<script type="text/javascript">$(function(){ App.Controller.initialize(); });</script>
{% if google_analytics_id is defined %}
<script>
Expand Down

0 comments on commit f9318ec

Please sign in to comment.