def run():
    """Main function
    """
    import argparse

    global LOGGER

    parser = argparse.ArgumentParser()
    parser.add_argument("-r", "--rotated", help="Time rotated log file")
    parser.add_argument("-v", "--verbose", help="print debug messages too",
                        action="store_true")
    parser.add_argument("-s", "--server", help="server to listen to",
                        default="localhost")
    parser.add_argument("-p", "--port", help="port to listen to",
                        default=16543,
                        type=int)
    opts = parser.parse_args()

    if opts.verbose:
        loglevel = logging.DEBUG
    else:
        loglevel = logging.INFO

    if opts.rotated:
        handler = logging.handlers.TimedRotatingFileHandler(opts.rotated,
                                                            when="midnight",
                                                            backupCount=7)
    else:
        handler = logging.StreamHandler()

    LOGGER = logging.getLogger("pytroll")
    LOGGER.setLevel(loglevel)

    handler.setLevel(loglevel)

    formatter = ColoredFormatter("[%(asctime)s %(levelname)-19s] %(message)s")
    handler.setFormatter(formatter)
    LOGGER.addHandler(handler)

    import time
    try:
        tlogger = Logger(opts.server, opts.port)
        # logger = Logger("safe", 16543)
        tlogger.start()
        while True:
            time.sleep(1)
    except KeyboardInterrupt:
        tlogger.stop()
        print("Thanks for using pytroll/logger. "
              "See you soon on www.pytroll.org!")
Main function