On 01-09-2016 11:11, Aline Manera wrote:
On 08/31/2016 06:06 PM, Lucio Correia wrote:
> That log file is not intended anymore to be a log file
> itself.
>
> Signed-off-by: Lucio Correia <luciojhc(a)linux.vnet.ibm.com>
> ---
> src/wok/config.py.in | 4 ++++
> src/wok/reqlogger.py | 6 +++---
> 2 files changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/src/wok/config.py.in b/src/wok/config.py.in
> index cbe585c..f82aa0a 100644
> --- a/src/wok/config.py.in
> +++ b/src/wok/config.py.in
> @@ -66,6 +66,10 @@ def get_object_store():
> return os.path.join(paths.state_dir, 'objectstore')
>
> +def get_data_dir():
> + return paths.state_dir
> +
> +
You don't need a new function. You can access paths directly wherever
you want.
OK
> def get_version():
> return "-".join([__version__, __release__])
>
> diff --git a/src/wok/reqlogger.py b/src/wok/reqlogger.py
> index 7a95907..92eff83 100644
> --- a/src/wok/reqlogger.py
> +++ b/src/wok/reqlogger.py
> @@ -29,7 +29,7 @@ import uuid
> from cherrypy.process.plugins import BackgroundTask
> from tempfile import NamedTemporaryFile
>
> -from wok.config import config, get_log_download_path
> +from wok.config import get_data_dir, get_log_download_path
> from wok.exception import InvalidParameter, OperationFailed
> from wok.message import WokMessage
> from wok.stringutils import ascii_dict
> @@ -60,7 +60,7 @@ TS_ZONE_FORMAT = "%Z"
> UNSAFE_REQUEST_PARAMETERS = ['password', 'passwd']
>
> # Log handler setup
> -REQUEST_LOG_FILE = "wok-req.log"
> +REQUEST_LOG_FILE = "user-requests.data"
> WOK_REQUEST_LOGGER = "wok_request_logger"
>
> # AsyncTask handling
> @@ -69,7 +69,7 @@ ASYNCTASK_REQUEST_METHOD = 'TASK'
>
> class RequestLogger(object):
> def __init__(self):
> - log = os.path.join(config.get("logging", "log_dir"),
> REQUEST_LOG_FILE)
> + log = os.path.join(get_data_dir(), REQUEST_LOG_FILE)
> h = logging.handlers.WatchedFileHandler(log, 'a')
> h.setFormatter(logging.Formatter('%(message)s'))
> self.handler = h
--
Lucio Correia
Software Engineer
IBM LTC Brazil