def warn(code, msg, suggestion): if code is None: raise Exception('Logging Format Error: Must have a code') if msg is None: return if isWarnEnabled() is False: return if suggestion is None: raise Exception('Logging Format Error: Must have a suggestion message') caller_frame_record = inspect.stack()[1] caller_frame = caller_frame_record[0] info = inspect.getframeinfo(caller_frame) filename = os.path.basename(info.filename) log_msg = "%s:%d WARN - {%s} %s; suggestion: %s" % ( filename, info.lineno, str(code), str(msg), str(suggestion)) try: capi.log(log_msg) except Exception, e: print "Failed to log message: {}:{} {}".format(filename, info.lineno, e) pass
def debug(msg): """ Write debug log """ if msg is None: return if isDebugEnabled() is False: return fname, lineno = _caller_info() log_msg = "%s:%d DEBUG - %s" % (fname, lineno, str(msg)) try: capi.log(log_msg) except Exception as ex: print("Failed to log message: {}:{} {}".format(fname, lineno, ex))
def trace(msg): """ Write trace log """ if msg is None: return if isTraceEnabled() is False: return fname, lineno = _caller_info() log_msg = "%s:%d TRACE - %s" % (fname, lineno, str(msg)) try: capi.log(log_msg) except Exception as ex: print("Failed to log message: {}:{} {}".format(fname, lineno, ex))
def trace(msg): if msg is None: return if isTraceEnabled() is False: return caller_frame_record = inspect.stack()[1] caller_frame = caller_frame_record[0] info = inspect.getframeinfo(caller_frame) filename = os.path.basename(info.filename) log_msg = "%s:%d TRACE - %s" % (filename, info.lineno, str(msg)) try: capi.log(log_msg) except Exception, e: print "Failed to log message: {}:{} {}".format(filename, info.lineno, e) pass
def info(code, msg): """ Write info log """ if code is None: raise Exception('Logging Format Error: Must have a code') if msg is None: return if isInfoEnabled() is False: return fname, lineno = _caller_info() log_msg = "%s:%d INFO - {%s} %s" % (fname, lineno, str(code), str(msg)) try: capi.log(log_msg) except Exception as ex: print("Failed to log message: {}:{} {}".format(fname, lineno, ex))
def fatal(code, msg, solution): """ Write fatal log """ if code is None: raise Exception('Logging Format Error: Must have a code') if msg is None: return if solution is None: raise Exception('Logging Format Error: Must have a solution message') fname, lineno = _caller_info() log_msg = "%s:%d FATAL - {%s} %s; solution: %s" % ( fname, lineno, str(code), str(msg), str(solution)) try: capi.log(log_msg) except Exception as ex: print("Failed to log message: {}:{} {}".format(fname, lineno, ex))
def warn(code, msg, suggestion): """ Write warn log """ if code is None: raise Exception('Logging Format Error: Must have a code') if msg is None: return if isWarnEnabled() is False: return if suggestion is None: raise Exception('Logging Format Error: Must have a suggestion message') fname, lineno = _caller_info() log_msg = "%s:%d WARN - {%s} %s; suggestion: %s" % ( fname, lineno, str(code), str(msg), str(suggestion)) try: capi.log(log_msg) except Exception as ex: print("Failed to log message: {}:{} {}".format(fname, lineno, ex))