Skip to content

Commit

Permalink
Merge pull request #86 from ucgJhe/master
Browse files Browse the repository at this point in the history
split log when multithread was disabled
  • Loading branch information
xwings committed Jan 29, 2020
2 parents a15d1a0 + f7ff72a commit 9bdd096
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions qiling/os/linux/thread.py
Expand Up @@ -233,10 +233,10 @@ def update_global_thread_id(self):
#global GLOBAL_THREAD_ID
self.ql.global_thread_id = os.getpid()

def set_thread_log_file(self, log_file):
if self.ql.log_split and log_file != None:
self.log_file_fd = open(log_file + "_" + str(os.getpid()) + '.' + str(self.thread_id), 'w+')
#logging.basicConfig(filename= log_file + "_" + str(os.getpid()) + ".qlog", filemode='w+', level=logging.DEBUG, format='%(message)s')
def set_thread_log_file(self, log_dir):
if self.ql.log_split and log_dir != None:
_logger = self.ql.log_file_fd
self.log_file_fd = ql_setup_logging_file(self.ql.output, log_dir, _logger)

def get_current_path(self):
return self.current_path
Expand Down
8 changes: 3 additions & 5 deletions qiling/os/posix/syscall.py
Expand Up @@ -1142,6 +1142,7 @@ def ql_syscall_rt_sigprocmask(ql, rt_sigprocmask_how, rt_sigprocmask_nset, rt_si


def ql_syscall_vfork(ql, null0, null1, null2, null3, null4, null5):
breakpoint()
pid = os.fork()

if pid == 0:
Expand All @@ -1152,12 +1153,9 @@ def ql_syscall_vfork(ql, null0, null1, null2, null3, null4, null5):
ql.thread_management.cur_thread.set_thread_log_file(ql.log_dir)
else:
if ql.log_split:
#ql.log_file = (ql.log_file + "_" + str(pid))
_logger = ql_setup_logging_stream(ql.output)
_logger = ql.log_file_fd
_logger = ql_setup_logging_file(ql.output, ql.log_file , _logger)
# if ql.log_dir != None:
# ql.log_file_fd = open(ql.log_dir + "_" + str(os.getpid()), 'w+')
#ql.log_file_fd = logging.basicConfig(filename=ql.log_file_name + "_" + str(os.getpid()) + ".qlog", filemode='w+', level=logging.DEBUG, format='%(message)s')
ql.log_file_fd = _logger
else:
regreturn = pid

Expand Down
6 changes: 4 additions & 2 deletions qiling/utils.py
Expand Up @@ -61,8 +61,10 @@ def ql_get_module_function(module_name, function_name):


def ql_setup_logger(logger_name=None):
if logger_name is None: # use random logger name to avoid share logger_name in unittesting
logger_name = 'qiling_%s' % random.random()
if logger_name is None: # increasing logger name counter to prevent conflict
loggers = logging.root.manager.loggerDict
_counter = len(loggers)
logger_name = 'qiling_%s' % _counter
logger = logging.getLogger(logger_name)
logger.setLevel(logging.DEBUG)
return logger
Expand Down

0 comments on commit 9bdd096

Please sign in to comment.