Commit d8b7ce94 by Victor Shnayder

Minor fixes to cms

* make logging work properly in cms, dev
* fix a comment
parent 341a7285
...@@ -176,7 +176,7 @@ def load_preview_state(request, preview_id, location): ...@@ -176,7 +176,7 @@ def load_preview_state(request, preview_id, location):
def save_preview_state(request, preview_id, location, instance_state, shared_state): def save_preview_state(request, preview_id, location, instance_state, shared_state):
""" """
Load the state of a preview module to the request Save the state of a preview module to the request
preview_id (str): An identifier specifying which preview this module is used for preview_id (str): An identifier specifying which preview this module is used for
location: The Location of the module to dispatch to location: The Location of the module to dispatch to
......
...@@ -2,13 +2,18 @@ ...@@ -2,13 +2,18 @@
This config file runs the simplest dev environment""" This config file runs the simplest dev environment"""
from .common import * from .common import *
from .logsettings import get_logger_config
import logging import logging
import sys import sys
logging.basicConfig(stream=sys.stdout, )
DEBUG = True DEBUG = True
TEMPLATE_DEBUG = DEBUG TEMPLATE_DEBUG = DEBUG
LOGGING = get_logger_config(ENV_ROOT / "log",
logging_env="dev",
tracking_filename="tracking.log",
debug=True)
MODULESTORE = { MODULESTORE = {
'default': { 'default': {
......
...@@ -3,19 +3,19 @@ import os.path ...@@ -3,19 +3,19 @@ import os.path
import platform import platform
import sys import sys
def get_logger_config(log_dir, def get_logger_config(log_dir,
logging_env="no_env", logging_env="no_env",
tracking_filename=None, tracking_filename=None,
syslog_addr=None, syslog_addr=None,
debug=False): debug=False):
"""Return the appropriate logging config dictionary. You should assign the """Return the appropriate logging config dictionary. You should assign the
result of this to the LOGGING var in your settings. The reason it's done result of this to the LOGGING var in your settings. The reason it's done
this way instead of registering directly is because I didn't want to worry this way instead of registering directly is because I didn't want to worry
about resetting the logging state if this is called multiple times when about resetting the logging state if this is called multiple times when
settings are extended.""" settings are extended."""
# If we're given an explicit place to put tracking logs, we do that (say for # If we're given an explicit place to put tracking logs, we do that (say for
# debugging). However, logging is not safe for multiple processes hitting # debugging). However, logging is not safe for multiple processes hitting
# the same file. So if it's left blank, we dynamically create the filename # the same file. So if it's left blank, we dynamically create the filename
# based on the PID of this worker process. # based on the PID of this worker process.
if tracking_filename: if tracking_filename:
...@@ -33,6 +33,7 @@ def get_logger_config(log_dir, ...@@ -33,6 +33,7 @@ def get_logger_config(log_dir,
return { return {
'version': 1, 'version': 1,
'disable_existing_loggers': False,
'formatters' : { 'formatters' : {
'standard' : { 'standard' : {
'format' : '%(asctime)s %(levelname)s %(process)d [%(name)s] %(filename)s:%(lineno)d - %(message)s', 'format' : '%(asctime)s %(levelname)s %(process)d [%(name)s] %(filename)s:%(lineno)d - %(message)s',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment