This is an automated email from the ASF dual-hosted git repository. mykolabodnar pushed a commit to branch DATALAB-2409 in repository https://gitbox.apache.org/repos/asf/incubator-datalab.git
commit ef5d4e822d212ce31d924b7cf9c241aaf27b7602 Author: bodnarmykola <[email protected]> AuthorDate: Tue Aug 3 10:49:33 2021 +0300 [DATALAB-2409] -logging refactored --- .../src/general/lib/os/fab.py | 11 -------- .../src/general/lib/os/logger.py | 32 ++++++++++++++++++++++ 2 files changed, 32 insertions(+), 11 deletions(-) diff --git a/infrastructure-provisioning/src/general/lib/os/fab.py b/infrastructure-provisioning/src/general/lib/os/fab.py index 68f9c3a..cf33332 100644 --- a/infrastructure-provisioning/src/general/lib/os/fab.py +++ b/infrastructure-provisioning/src/general/lib/os/fab.py @@ -22,7 +22,6 @@ import csv import datetime import json -import logging import os import random import re @@ -38,16 +37,6 @@ from fabric import * from patchwork.files import exists from patchwork import files -local_log_filename = "{}_{}.log".format(os.environ['conf_resource'], os.environ['request_id']) -local_log_filepath = "/logs/" + os.environ['conf_resource'] + "/" + local_log_filename -logging.basicConfig(format='%(levelname)-8s [%(asctime)s] %(message)s', - level=logging.DEBUG, - filename='{}'.format(local_log_filepath), - filemode='w') -console = logging.StreamHandler() -console.setLevel(logging.INFO) -logging.getLogger('').addHandler(console) - def ensure_python_venv(python_venv_version): try: if not exists(conn, '/opt/python/python{}'.format(python_venv_version)): diff --git a/infrastructure-provisioning/src/general/lib/os/logger.py b/infrastructure-provisioning/src/general/lib/os/logger.py new file mode 100644 index 0000000..ad7c3b5 --- /dev/null +++ b/infrastructure-provisioning/src/general/lib/os/logger.py @@ -0,0 +1,32 @@ +# ***************************************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +# ****************************************************************************** + +import logging + +local_log_filename = "{}_{}.log".format(os.environ['conf_resource'], os.environ['request_id']) +local_log_filepath = "/logs/" + os.environ['conf_resource'] + "/" + local_log_filename +logging.basicConfig(format='%(levelname)-8s [%(asctime)s] %(message)s', + level=logging.DEBUG, + filename='{}'.format(local_log_filepath), + filemode='w') +console = logging.StreamHandler() +console.setLevel(logging.INFO) +logging.getLogger('').addHandler(console) \ No newline at end of file --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
