logging: Log management commands that are run.

This could potentially help with debugging exactly what happened with
some issue down the line.

(imported from commit cc7321d742875b644d4727a084b462dcd01dcf10)
This commit is contained in:
Tim Abbott 2013-11-18 18:04:45 -05:00
parent 2955cac47e
commit 6c7489ed88
4 changed files with 33 additions and 2 deletions

16
bin/log-management-command Executable file
View File

@ -0,0 +1,16 @@
#!/usr/bin/env python
import sys
import logging
import os
sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "zproject.settings")
from django.conf import settings
logger = logging.getLogger("zulip.management")
file_handler = logging.FileHandler(settings.MANAGEMENT_LOG_PATH)
formatter = logging.Formatter("%(asctime)s: %(message)s")
file_handler.setFormatter(formatter)
logger.addHandler(file_handler)
logger.setLevel(logging.INFO)
logger.info("Ran '%s'" % (sys.argv[1],))

View File

@ -1,14 +1,21 @@
#!/usr/bin/env python #!/usr/bin/env python
import os import os
import sys import sys
import logging
import subprocess
if __name__ == "__main__": if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "zproject.settings")
from django.conf import settings
logger = logging.getLogger("zulip.management")
subprocess.check_call([os.path.join(os.path.dirname(__file__), "bin", "log-management-command"),
" ".join(sys.argv)])
if "--no-traceback" not in sys.argv and len(sys.argv) > 1: if "--no-traceback" not in sys.argv and len(sys.argv) > 1:
sys.argv.append("--traceback") sys.argv.append("--traceback")
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "zproject.settings")
from django.core.management import execute_from_command_line from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv) execute_from_command_line(sys.argv)

View File

@ -587,6 +587,7 @@ CACHES = {
if DEPLOYED: if DEPLOYED:
SERVER_LOG_PATH = "/var/log/zulip/server.log" SERVER_LOG_PATH = "/var/log/zulip/server.log"
MANAGEMENT_LOG_PATH = "/var/log/zulip/manage.log"
WORKER_LOG_PATH = "/var/log/zulip/workers.log" WORKER_LOG_PATH = "/var/log/zulip/workers.log"
if ENTERPRISE: if ENTERPRISE:
EVENT_LOG_DIR = None EVENT_LOG_DIR = None
@ -601,6 +602,7 @@ if DEPLOYED:
else: else:
EVENT_LOG_DIR = 'event_log' EVENT_LOG_DIR = 'event_log'
SERVER_LOG_PATH = "server.log" SERVER_LOG_PATH = "server.log"
MANAGEMENT_LOG_PATH = "manage.log"
WORKER_LOG_PATH = "workers.log" WORKER_LOG_PATH = "workers.log"
STATS_DIR = 'stats' STATS_DIR = 'stats'
PERSISTENT_QUEUE_FILENAME = "event_queues.pickle" PERSISTENT_QUEUE_FILENAME = "event_queues.pickle"
@ -683,6 +685,11 @@ LOGGING = {
'level': 'INFO', 'level': 'INFO',
'propagate': False, 'propagate': False,
}, },
'zulip.management': {
'handlers': ['file'],
'level': 'INFO',
'propagate': False,
},
## Uncomment the following to get all database queries logged to the console ## Uncomment the following to get all database queries logged to the console
# 'django.db': { # 'django.db': {
# 'handlers': ['console'], # 'handlers': ['console'],

View File

@ -48,3 +48,4 @@ CACHES['database'] = {
} }
LOGGING['loggers']['zulip.requests']['level'] = 'CRITICAL' LOGGING['loggers']['zulip.requests']['level'] = 'CRITICAL'
LOGGING['loggers']['zulip.management']['level'] = 'CRITICAL'