def setup_logging(options):
    if not os.path.exists(settings.LOGDIR):
        os.makedirs(settings.LOGDIR, 0755)

    logFileName = "worker%d.log" % settings.PORT
    logFile = os.path.join(settings.LOGDIR, logFileName)

    fileHandler = logging.handlers.RotatingFileHandler(logFile, 'w', config.LOG_SIZE, config.LOG_BACKUPS, "UTF-8")
    fileHandler.setFormatter(logging.Formatter("%(asctime)s - %(name)s - %(levelname)6s - %(message)s"))
    logger = logging.getLogger()
    logger.addHandler(fileHandler)

    if options.CONSOLE:
        consoleHandler = logging.StreamHandler()
        consoleHandler.setFormatter(logging.Formatter("%(asctime)s - %(levelname)6s [%(name)s] %(message)s"))
        consoleHandler.setLevel(logging.DEBUG)
        logger.setLevel(logging.DEBUG)
        logger.addHandler(consoleHandler)

    logLevel = logging.DEBUG if options.DEBUG else logging.INFO
    logging.getLogger().setLevel(logLevel)
dataset/ETHPy150Open mikrosimage/OpenRenderManagement/src/octopus/workerd.py/setup_logging/original