Fixed pathhandling in custom logger routine.
This commit is contained in:
parent
202067d6dd
commit
bb363798de
1 changed files with 13 additions and 11 deletions
|
|
@ -1,18 +1,15 @@
|
||||||
"""
|
"""
|
||||||
Logging facilities
|
Logging facilities
|
||||||
|
|
||||||
These are thin wrappers on top of Twisted's
|
These are thin wrappers on top of Twisted's logging facilities; logs
|
||||||
logging facilities; logs are all directed
|
are all directed either to stdout (if Evennia is running in
|
||||||
either to stdout (if Evennia is running in
|
|
||||||
interactive mode) or to game/logs.
|
interactive mode) or to game/logs.
|
||||||
|
|
||||||
The log_file() function uses its own threading
|
The log_file() function uses its own threading system to log to
|
||||||
system to log to arbitrary files in game/logs.
|
arbitrary files in game/logs.
|
||||||
|
|
||||||
Note:
|
Note: All logging functions have two aliases, log_type() and
|
||||||
All logging functions have two aliases,
|
log_typemsg(). This is for historical, back-compatible reasons.
|
||||||
log_type() and log_typemsg(). This is for
|
|
||||||
historical, back-compatible reasons.
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
@ -22,6 +19,7 @@ from traceback import format_exc
|
||||||
from twisted.python import log
|
from twisted.python import log
|
||||||
from twisted.internet.threads import deferToThread
|
from twisted.internet.threads import deferToThread
|
||||||
|
|
||||||
|
_LOGDIR = None
|
||||||
|
|
||||||
def log_trace(errmsg=None):
|
def log_trace(errmsg=None):
|
||||||
"""
|
"""
|
||||||
|
|
@ -116,7 +114,11 @@ def log_file(msg, filename="game.log"):
|
||||||
'game.log'. All logs will appear in the logs directory and log
|
'game.log'. All logs will appear in the logs directory and log
|
||||||
entries will start on new lines following datetime info.
|
entries will start on new lines following datetime info.
|
||||||
"""
|
"""
|
||||||
global LOG_FILE_HANDLES
|
global LOG_FILE_HANDLES, _LOGDIR
|
||||||
|
|
||||||
|
if not _LOGDIR:
|
||||||
|
from django.conf import settings
|
||||||
|
_LOGDIR = settings.LOG_DIR
|
||||||
|
|
||||||
def callback(filehandle, msg):
|
def callback(filehandle, msg):
|
||||||
"Writing to file and flushing result"
|
"Writing to file and flushing result"
|
||||||
|
|
@ -131,7 +133,7 @@ def log_file(msg, filename="game.log"):
|
||||||
log_trace()
|
log_trace()
|
||||||
|
|
||||||
# save to server/logs/ directory
|
# save to server/logs/ directory
|
||||||
filename = os.path.join("server", "logs", filename)
|
filename = os.path.join(_LOGDIR, filename)
|
||||||
|
|
||||||
if filename in LOG_FILE_HANDLES:
|
if filename in LOG_FILE_HANDLES:
|
||||||
filehandle = LOG_FILE_HANDLES[filename]
|
filehandle = LOG_FILE_HANDLES[filename]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue