diff --git a/thousands/__init__.py b/thousands/__init__.py index 816bb33..d675ffa 100644 --- a/thousands/__init__.py +++ b/thousands/__init__.py @@ -27,34 +27,39 @@ app.config.from_pyfile(os.path.join(os.environ['OPENSHIFT_DATA_DIR'], 'thousands.conf')) -loggers = [ app.logger, logging.getLogger('yoyo') ] - -if 'LOGDIR' in app.config: - main_handler = logging.handlers.RotatingFileHandler( - os.path.join(app.config['LOGDIR'], 'thousands.log'), - maxBytes=1024*1024*1024, - backupCount=10, - encoding='utf-8') -else: - main_handler = logging.StreamHandler() - -main_handler.setLevel(logging.DEBUG) -handlers = [main_handler] - -if 'ADMIN_MAIL' in app.config: - mail_handler = SMTPHandler(app.config['SMTP_HOST'], - app.config['SMTP_FROMADDR'], - app.config['ADMIN_MAIL'], - 'Thousands app failed', - (app.config['SMTP_USER'], app.config['SMTP_PASSWORD']), - ()) - mail_handler.setLevel(logging.ERROR) - handlers.append(mail_handler) - -for logger in loggers: - for handler in handlers: - logger.addHandler(handler) +if not app.debug: + loggers = [ app.logger, logging.getLogger('yoyo') ] + + if 'LOGDIR' in app.config: + main_handler = logging.handlers.RotatingFileHandler( + os.path.join(app.config['LOGDIR'], 'thousands.log'), + maxBytes=1024*1024*1024, + backupCount=10, + encoding='utf-8') + else: + main_handler = logging.StreamHandler() + + formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') + main_handler.setFormatter(formatter) + + map(lambda x: x.addHandler(main_handler), loggers) + app.logger.setLevel(logging.INFO) + if 'ADMIN_MAIL' in app.config: + mail_handler = SMTPHandler( + app.config['SMTP_HOST'], + app.config['SMTP_FROMADDR'], + app.config['ADMIN_MAIL'], + 'Thousands app failed', + (app.config['SMTP_USER'], app.config['SMTP_PASSWORD']), + ()) + mail_handler.setLevel(logging.ERROR) + mail_handler.setFormatter(formatter) + map(lambda x: x.addHandler(mail_handler), loggers) + +else: + logging.getLogger('yoyo').addHandler(logging.StreamHandler()) + psycopg2.extensions.register_type(psycopg2.extensions.UNICODE) pool = psycopg2.pool.SimpleConnectionPool(1, 10, app.config['PG_DSN']) diff --git a/thousands/auth.py b/thousands/auth.py index 0c9b280..6de1421 100644 --- a/thousands/auth.py +++ b/thousands/auth.py @@ -90,6 +90,10 @@ def oauth_login(req, flow, get_user): if user is not None: login_user(user) if created: + app.logger.info("New user registration uid=%s, src=%s, name=%s", + user.get_id(), + user.src, + user.name) flash(u'Регистрация завершена') return redirect(url_for('user', user_id=user.get_id())) else: diff --git a/thousands/static/style.css b/thousands/static/style.css index 38f098f..f97fea9 100644 --- a/thousands/static/style.css +++ b/thousands/static/style.css @@ -59,3 +59,7 @@ a.anchor { top: -60px; visibility: hidden; } + +.flash-message { + margin-top: 20px; +} diff --git a/thousands/templates/summit.html b/thousands/templates/summit.html index aac4df8..6197980 100644 --- a/thousands/templates/summit.html +++ b/thousands/templates/summit.html @@ -4,7 +4,7 @@ {% block content %} {% with messages = get_flashed_messages() %} {% if messages %} -