2 # Copyright (c) 2016 Samsung Electronics Co., Ltd
4 # Licensed under the Flora License, Version 1.1 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://floralicense.org/license/
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
19 import logging.handlers
23 LOG_FILE_MAX_BYTES=10*1024*1024
24 TIC_LOG_DIR='/var/tmp/tic-core/log'
27 logger = logging.getLogger(root)
28 logger.setLevel(logging.DEBUG)
30 formatter = logging.Formatter('%(asctime)s [%(levelname)s][%(filename)s(%(lineno)s)-%(funcName)s()] %(message)s')
31 formatter.datefmt = '%Y-%m-%d %H:%M:%S'
34 fileHandler = logging.handlers.RotatingFileHandler(os.path.join(TIC_LOG_DIR, 'tic-core.log'), maxBytes=LOG_FILE_MAX_BYTES, backupCount=10)
35 streamHandler = logging.StreamHandler()
37 fileHandler.setFormatter(formatter)
38 streamHandler.setFormatter(formatter)
40 logger.addHandler(fileHandler)
41 logger.addHandler(streamHandler)
46 except OSError as err:
47 if err.errno != errno.EEXIST: