(text, **kwargs)
Used to log and print concurrently
Used to log and print concurrently
Used to log and print concurrently
def tee(text, **kwargs):
    """Used to log and print concurrently"""

    # Defining variables to print color-coded messages to the console.
    colors = {'green': '\033[92m',
              'blue': '\033[94m',
              'orange': '\033[93m',
              'red': '\033[91m',}
    end_color = '\033[0m'
    boxes = {'ok': colors['blue'] + '[*] ' + end_color,
             'note': colors['green'] + '[+] ' + end_color,
             'warn': colors['orange'] + '[!] ' + end_color,
             'vuln': colors['red'] + '[VULNERABLE] ' + end_color,
             'sus': colors['orange'] + '[INVESTIGATE] ' + end_color}

    # If this function is called with an optional 'box=xxx' parameter, these
    # will be prepended to the message.
    box = kwargs.get('box', '')
    if box:
        box = boxes[box]

    # First, just print the item to the console.
    print(box + text)

    # Then, write it to the log if logging is not disabled
    if not ARGS.nologging:
        try:
            with open(LOGFILE, 'a') as logfile:
                logfile.write(box + text + '\n')
        except PermissionError:
            ARGS.nologging = True
            print(boxes['warn'] + "Could not create a log file due to"
                  " insufficient permissions. Continuing with checks...")
def tee ( text , * * kwargs ) : # Defining variables to print color-coded messages to the console. colors = { 'green' : '\033[92m' , 'blue' : '\033[94m' , 'orange' : '\033[93m' , 'red' : '\033[91m' , } end_color = '\033[0m' boxes = { 'ok' : colors [ 'blue' ] + '[*] ' + end_color , 'note' : colors [ 'green' ] + '[+] ' + end_color , 'warn' : colors [ 'orange' ] + '[!] ' + end_color , 'vuln' : colors [ 'red' ] + '[VULNERABLE] ' + end_color , 'sus' : colors [ 'orange' ] + '[INVESTIGATE] ' + end_color } # If this function is called with an optional 'box=xxx' parameter, these # will be prepended to the message. box = kwargs . get ( 'box' , '' ) if box : box = boxes [ box ] # First, just print the item to the console. print ( box + text ) # Then, write it to the log if logging is not disabled if not ARGS . nologging : try : with open ( LOGFILE , 'a' ) as logfile : logfile . write ( box + text + '\n' ) except PermissionError : ARGS . nologging = True print ( boxes [ 'warn' ] + "Could not create a log file due to" " insufficient permissions. Continuing with checks..." )