def enable():
    print('Content-type: text/html \n')

def displayError():
    import subprocess
    error_log_file = '/var/log/httpd/error_log'
    num_lines      = str(-5)
    proc = subprocess.Popen(['tail', num_lines, error_log_file], stdout=subprocess.PIPE)
    lines = proc.stdout.readlines()
    for line in lines:
        line = line.decode("utf-8")     
        print(line, '<br>')
    
def traceback():
    import sys
    import traceback
    ex_type, ex_value, ex_traceback = sys.exc_info()

    # Extract unformatter stack traces as tuples
    trace_back = traceback.extract_tb(ex_traceback)

    # Format stacktrace
    stack_trace = list()

    for trace in trace_back:
        stack_trace.append("File : %s , Line : %d, Func.Name : %s, Message : %s" % (trace[0], trace[1], trace[2], trace[3]))

    print("Exception type: %s"    %ex_type.__name__)
    print("Exception message: %s" %ex_value)
    print("Stack trace: %s"       %stack_trace)