def __init__(self): Logger.__init__(self, "netgen") ch = logging.StreamHandler() formatter = logging.Formatter(MSG_FORMAT) ch.setFormatter(formatter) self.addHandler(ch) self.setLogLevel()
def __init__(self, config, name, *args, **kwargs): Logger.__init__(self, name, *args, **kwargs) log_format = "temboard[%(process)d]: [%(name)s] %(levelname)s: %(message)s" if config.logging['level'] == 'DEBUG': # Add extra informations when we are in DEBUG mode. log_format = "temboard[%(process)d]: [%(name)s] [%(funcName)s@" log_format += "%(pathname)s#L%(lineno)d] %(levelname)s: %(message)s" if config.logging['method'] == 'syslog': try: # Instanciate a new syslog handler. lh = SysLogHandler( address=str(config.logging['destination']), facility=LOG_FACILITIES[config.logging['facility']]) except socket.error as e: raise ConfigurationError(e) elif config.logging['method'] == 'file': try: # Instanciate a new file handler. lh = FileHandler(filename=config.logging['destination'], mode='a') # Add timestamp when using a FileHandler. log_format = "%(asctime)s " + log_format except IOError as e: raise ConfigurationError(e) # Set log level according to the level defined in configuration files. lh.setLevel(LOG_LEVELS[config.logging['level']]) lh.setFormatter(Formatter(log_format)) self.addHandler(lh)
def __init__(self): Logger.__init__(self, "ravel") ch = logging.StreamHandler() formatter = logging.Formatter(MSG_FORMAT) ch.setFormatter(formatter) self.addHandler(ch) self.setLogLevel()
def __init__(self,name): ''' new constructor already setting up the different handlers and formatters ''' Logger.__init__(self,name) #Flag whether a file log should be created fileLog = True #Checking whether there is a folder for logging if not os.path.isdir(os.path.dirname(logFile)): fileLog = False #If our log file exists we delete it to have a new log file for every run if os.path.isfile(logFile) and fileLog: try: os.remove(logFile) except: pass if fileLog: self.setFileHandler() self.addHandler(zeroLogger._FileHandle) self.setStreamHandler() self.addHandler(zeroLogger._StreamHandle)
def __init__(self, name, level): Logger.__init__(self, name, level) self.formatter = self.format self.handler = PMLogHandler() self.handler.setFormatter(self.formatter) self.addHandler(self.handler)
def __init__(self, name, level=0): Logger.__init__(self, name, level) self.formatter = self.format handler = StreamHandler() handler.setFormatter(self.formatter) self.addHandler(handler)
def __init__(self, name : str, logLevel : LogLevel=LogLevel.INFO, handlers : Optional[List[Handler]]=None, logFormat : Optional[str] \ ='[%(name)s] Line %(lineno)d %(levelname)s: %(message)s') -> None: ''' Initializes the ArkoudaLogger with the name, level, logFormat, and handlers parameters Parameters ---------- name : str The logger name, prepends all logging errors logLevel : LogLevel The desired log level in the form of a LogLevel enum value, defaults to INFO handlers : List[Handler] A list of logging.Handler objects, if None, a list consisting of one StreamHandler named 'console-handler' is generated and configured logFormat : str Defines the string template used to format all log messages, defaults to '[%(name)s] Line %(lineno)d %(levelname)s: %(message)s' Return ------ None Notes ----- ArkoudaLogger is derived from logging.Logger and adds convenience methods and enum-enforced parameter control to prevent runtime errors. The default list of Handler objects consists of a single a StreamHandler that writes log messages to stdout with a format that outputs a message such as the following: [LoggerTest] Line 24 DEBUG: debug message Important note: if a list of 1..n logging.Handler objects is passed in, and dynamic changes to 1..n handlers is desired, set a name for each Handler object as follows: handler.name = <desired name>. Setting the Handler names will enable dynamic changes to specific Handlers be retrieving by name the Handler object to be updated. The Logger-scoped level is set to DEBUG to enable fine-grained control at the Handler level as a higher level would disable DEBUG-level logging in the individual handlers. ''' Logger.__init__(self, name=name, level=DEBUG) if handlers is None: handler = cast(Handler,StreamHandler()) handler.name = 'console-handler' handler.setLevel(logLevel.value) handlers = [handler] for handler in handlers: if logFormat: handler.setFormatter(Formatter(logFormat)) self.addHandler(handler)
def __init__(self, bot=None, stdout_print=True): if bot is None: bot = BOT self.bot = bot Logger.__init__(self, 'botlogger') self.setLevel(logging.INFO) self.addHandler(BotHandler(BOT)) if stdout_print: self.addHandler(logging.StreamHandler(sys.stdout))
def __init__(self, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", *args, **kwargs): self.formatter = logging.Formatter(format) Logger.__init__(self, self.__class__.__name__, *args, **kwargs) self.addHandler(self.get_console_handler())
def __init__(self, name, level=DEBUG): Logger.__init__(self, name, level) console = StreamHandler() console.setFormatter( PrettyLevelsFormatter( color("[${asctime}]", fg="grey") + " ${levelname} " + color("(${name}): ", fg="grey") + "${message}", style="$")) self.addHandler(console)
def __init__(self, name): Logger.__init__(self, name) self.computer = os.environ['COMPUTERNAME'] name = os.path.basename(sys.argv[0]).split('.')[0] if name.find('-') <> -1: app = name.split('-')[1] else: app = name self.application = app
def __init__(self, name, level=0): if level == 0: level = option_parser.get_verbose() Logger.__init__(self, name, level) self.formatter = self.format handler = StreamHandler() handler.setFormatter(self.formatter) self.addHandler(handler)
def __init__(self): Logger.__init__(self, "OVS-CONSOLE") # Create console handler console = logging.StreamHandler() # Add console handler to logging handler self.addHandler(console) # Setting Logging LEVEL self.setLevel(LEVEL)
def __init__(self, name = 'MedPyLogger', level = 0) : # To guarantee that no one created more than one instance of Logger: if not Logger._instance == None : raise RuntimeError('Only one instance of Logger is allowed!') # initialize parent NativeLogger.__init__(self, name, level) # set attributes self.setHandler(logging.StreamHandler(sys.stdout)) self.setLevel(logging.WARNING)
def __init__(self, name, level=logging.NOTSET): """ :param name: name of the logger. Usually set to package name using __name__ :param level: Verbosity level (use logging package enums) """ Logger.__init__(self, name, level) self._file_logging_enabled = False self._file_handler = None self._stream_handler = None self._conf_file_exists = False self._warning_omitted = False
def __init__(self, diretorio: str, console: bool=False, nome: str='log', nivel: int=NOTSET): if not isdir(diretorio): mkdir(diretorio) Logger.__init__(self, nome, nivel) formato = Formatter('%(asctime)s - %(process)d - %(levelname)s - %(message)s', '%Y/%m/%d - %H:%M:%S') arquivo = FileHandler(join(diretorio, strftime('%Y-%m-%d') + '.log')) arquivo.setFormatter(formato) self.addHandler(arquivo) if console: console = StreamHandler() console.setFormatter(formato) self.addHandler(console)
def __init__(self, name, level=0, file_output=None, console=True): Logger.__init__(self, name, level) self.formatter = self.format if console: handler = StreamHandler() handler.setFormatter(self.formatter) self.addHandler(handler) if file_output: handler = FileHandler(file_output) handler.setFormatter(self.formatter) self.addHandler(handler)
def __init__(self): level = logging.INFO if self.LOG_LEVEL in os.environ and \ os.environ[self.LOG_LEVEL] == 'debug': level = logging.DEBUG Logger.__init__(self, self.LOG_NAME, level) log_file = RotatingFileHandler(os.path.expanduser(self.LOG_FILE), maxBytes=self.LOG_SIZE, backupCount=self.LOG_COUNT) log_file.setFormatter(Formatter(self.LOG_FORMAT)) self.addHandler(log_file)
def __init__(self): Logger.__init__(self, "sdnctrlsim") # create console handler ch = StreamHandlerNoNewline() # create formatter formatter = logging.Formatter(LOGMSGFORMAT) # add formatter to ch ch.setFormatter(formatter) # add ch to lg self.addHandler(ch) self.setLogLevel()
def __init__( self ): Logger.__init__( self, "sdnctrlsim" ) # create console handler ch = StreamHandlerNoNewline() # create formatter formatter = logging.Formatter( LOGMSGFORMAT ) # add formatter to ch ch.setFormatter( formatter ) # add ch to lg self.addHandler( ch ) self.setLogLevel()
def __init__(self, log_path=None, log_file=None, log_format='%(asctime)s - %(levelname)s - %(message)s', *args, **kwargs): if not os.path.isdir(log_path): os.mkdir(log_path, 0o770) self.formatter = logging.Formatter(log_format) self.log_file = '{0}/{1}'.format(log_path, log_file) Logger.__init__(self, *args, **kwargs) self.addHandler(self.set_console_handler()) if log_file: self.addHandler(self.set_file_handler()) self.propagate = False
def __init__(self): Logger.__init__(self, "EasyOVS") # create console handler ch = StreamHandlerNoNewline(sys.stdout) # create formatter formatter = logging.Formatter(LOGMSGFORMAT) # add formatter to ch ch.setFormatter(formatter) # add ch to lg self.addHandler(ch) self.set_log_level()
def __init__(self, name: str, level: Optional[int] = logging.NOTSET): """ Initialize the IgnisLogger object Args: name: name of the logger. Usually set to package name using __name__ level(logging.NOTSET): Verbosity level (use logging package enums) """ Logger.__init__(self, name, level) self._file_logging_enabled = False self._file_handler = None self._stream_handler = None self._conf_file_exists = False self._warning_omitted = False
def __init__(self, name="mininet"): Logger.__init__(self, name) # create console handler ch = StreamHandlerNoNewline() # create formatter formatter = logging.Formatter(LOGMSGFORMAT) # add formatter to ch ch.setFormatter(formatter) # add ch to lg and initialize log level self.addHandler(ch) self.ch = ch self.setLogLevel()
def __init__(self, name, level=0, file_output=None): Logger.__init__(self, name, level) self.formatter = self.format if file_output: handler = FileHandler(file_output) else: if gs.log == "File" and file_output: handler = FileHandler(gs.log_file) else: handler = StreamHandler() handler.setFormatter(self.formatter) self.addHandler(handler)
def __init__( self, log_file=None, log_format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", *args, **kwargs): self.formatter = logging.Formatter(log_format) self.log_file = log_file Logger.__init__(self, *args, **kwargs) self.addHandler(self.get_console_handler()) if log_file: self.addHandler(self.get_file_handler()) # with this pattern, it's rarely necessary to propagate the| error up to parent self.propagate = False
def __init__(self, name='', *args, **kwargs): _Logger.__init__(self, name, *args, **kwargs) self.propagate = 0 level = locals().get(defaultConfig()['logging']['logging'].get(name)) if not name: handler = StreamHandler() handler.setFormatter(StreamFormatter(ROOT_LOG_FORMAT)) elif name in ['status', '(status)']: handler = StatusHandler() handler.setFormatter(StreamFormatter(STATUS_FORMAT)) level = INFO else: handler = StreamHandler() handler.setFormatter(StreamFormatter(LOG_FORMAT)) self.addHandler(handler) if level is not None: self.setLevel(level)
def __init__(self, log_file, console=False, log_format=DEFAULT_LOG_FORMAT, *args, **kwargs): self.formatter = logging.Formatter(log_format) self.log_file = log_file Logger.__init__(self, *args, **kwargs) # self.addHandler(self.get_console_handler()) # if log_file: self.addHandler(self.get_file_handler()) if console: self.addHandler(self.get_console_handler()) self.propagate = False
def __init__(self, name, log_file_path=None, console_level=INFO, file_level=DEBUG): """ Init method of 'ColoredLogger' class. :param name: Name of logger. :param log_file_path: If you want to create a log file, you have to set this parameter. It should be the path of log file. :param console_level: Set the log level of console output. :param file_level: Set the log level of log file. """ Logger.__init__(self, name) color_formatter = ColoredFormatter(self.COLOR_FORMAT) if log_file_path: log_folder_path = "{}".format(os_sep).join( log_file_path.split(os_sep)[0:-1]) if not isdir(log_folder_path): try: mkdir(log_folder_path) except OSError as exc: if exc.errno != errno.EEXIST: raise exc pass # create file handler which logs even debug messages log_file_formatter = ColoredFormatter(self.LOG_FILE_FORMAT, use_color=False) fh = FileHandler(log_file_path, mode="w") fh.setLevel(file_level) fh.setFormatter(log_file_formatter) self.addHandler(fh) console = StreamHandler() console.setLevel(console_level) console.setFormatter(color_formatter) self.addHandler(console) return
def __init__(self, name="Main Logger", handlers=None, stderr=True): """ :param name: Name of the logger, Default "Main Logger" :param handlers: List of handlers to attach :param stderr: If true, default StreamHandler to stderr is attached :return: """ Logger.__init__(self, name) self.setLevel(logging.DEBUG) self.propagate = False if handlers and len(handlers) > 0: for handler in handlers: if isinstance(handler, logging.Handler): handler.setFormatter(self.FORMATTER) self.addHandler(handler) if stderr: self.stderrHandler = self.addStreamHandler()
def __init__(self): Logger.__init__(self, None) self.parent = root = getLogger() if not root.handlers: root.addHandler(self.default_root_handler) self._db = None self._record_queue = deque() self._record_size = 0 self._async = set() l = threading.Lock() self._acquire = l.acquire release = l.release def _release(): try: while self._async: self._async.pop()(self) finally: release() self._release = _release self.backlog()
def __init__(self, filename, level=logging.INFO): _Logger.__init__(self, filename, level) formatter = logging.Formatter( "%(name)-12s %(asctime)s level-%(levelname)-8s thread-%(thread)-8d \n%(message)s\n--end--" ) fileTimeHandler = TimedRotatingFileHandler( "{0}{1}{2}".format(BASIC_LOG_PATH, os.sep, filename), "H", 1, 10, encoding="utf-8" ) fileTimeHandler.suffix = "%Y%m%d%H.log" fileTimeHandler.setFormatter(formatter) fileTimeHandler.setLevel(level) self.addHandler(fileTimeHandler) console = StreamHandler() console.setLevel(level) console.setFormatter(formatter) self.addHandler(console) self.handler = fileTimeHandler
def __init__(self, name='', *args, **kwargs): _Logger.__init__(self, name, *args, **kwargs) self.propagate = 0 try: level = eval(_config['logging'][name]) except: level = None if not name: handler = StreamHandler() handler.setFormatter(StreamFormatter(ROOT_LOG_FORMAT)) elif name in ['status', '(status)']: handler = StatusHandler() handler.setFormatter(StreamFormatter(STATUS_FORMAT)) level = INFO else: handler = StreamHandler() handler.setFormatter(StreamFormatter(LOG_FORMAT)) self.addHandler(handler) if level is not None: self.setLevel(level)
def __init__(self, logger_name, user_name=None, host=None, sender=None, max_batch=DEFAULT_MAX_BATCH, min_batch=DEFAULT_MIN_BATCH, max_history_len=DEFAULT_MAX_HISTORY_LEN, max_tim_to_update=DEFAULT_MAX_TIME_TO_UPDATE, level=30, **kwargs): """ :param logger_name: name for current logger :param user_name: for authentication :param host: for authentication :param sender: used only for non ServerSender. For example for test use TestSender :param max_batch: sending params :param min_batch: sending params :param max_history_len: max size for query :param max_tim_to_update: send batch with size less then min_batch after max_tim_to_update seconds :param kwargs: """ if sender is None: assert isinstance(user_name, str), "user_name must be string" assert isinstance(host, str), "host must be string" user_token = os.environ["LOGGER_TOKEN"] sender = ServerSender(user_name, user_token, host) kwargs['level'] = level Logger.__init__(self, "TBL " + logger_name, **kwargs) self._handler = ProducerHandler( sender, logger_name, max_batch=max_batch, min_batch=min_batch, max_history_len=max_history_len, max_time_to_update=max_tim_to_update, level=level, ) self.addHandler(self._handler)
def __init__(self): Logger.__init__(self, None) self.parent = root = getLogger() if not root.handlers: root.addHandler(self.default_root_handler) self.__reset() self._nid_dict = {} self._async = set() l = threading.Lock() self._acquire = l.acquire release = l.release def _release(): try: while self._async: self._async.pop()(self) finally: release() self._release = _release self.backlog()
def __init__( self, log_file=None, log_format="%(asctime)s - %(name)s - %(levelname)s - %(funcName)s - %(message)s", log_path='', *args, **kwargs): self.formatter = logging.Formatter(log_format) if log_path: if not os.path.exists(log_path): os.makedirs(log_path) self.log_file = os.path.join(log_path, log_file) Logger.__init__(self, *args, **kwargs) self.addHandler(self.get_console_handler()) if log_file: self.addHandler(self.get_file_handler()) # with this pattern, it's rarely necessary to propagate the| error up to parent self.propagate = False
def __init__(self): """Selena logger constructor Creates the main instance of the Selena logging module. """ Logger.__init__(self, "selena") # create console handler and set level to debug ch = logging.StreamHandler() ch.setLevel(DEFAULT_LOG_LEVEL) # create formatter formatter = logging.Formatter(DEFAULT_LOG_FORMAT) # add formatter to ch ch.setFormatter(formatter) # add ch to logger self.addHandler(ch) # set the logger level self.setLevel(DEFAULT_LOG_LEVEL)
def __init__(self, name, verbosity_offset): Logger.__init__(self, name) # overwritten by set_offset # this is an emulation of the Logger level for dots self._offset = verbosity_offset self._iterations = 0 self._progress_every = 0 self._dot_every = 1 self._percent_print_every = 0 self._next_percent_print = _NEVER_PERCENT_VALUE self._percent_target = _NEVER_PERCENT_VALUE formatter = Formatter(fmt="[%(name)s] %(message)s") handler = StreamHandler(sys.stdout) handler.setFormatter(formatter) self.addHandler(handler) self.set_offset(verbosity_offset) self._dot_char = DEFAULT_DOT_CHAR
def __init__(self, *args, **kwargs): Logger.__init__(self, *args, **kwargs) ConductLogger._storeLoggerNameLength(self)
def __init__(self, status=None, module_logger=None): Logger.__init__(self, "logger") if module_logger: self.addHandler(CommandHandler(module_logger)) if status: self.addHandler(StatusHandler(status))
def __init__(self, *args, **kwargs): Logger.__init__(self, *args, **kwargs) self._indent_level = 0
def __init__(self): Logger.__init__(self,"PluginLogger")
def __init__(self, name): Logger.__init__(self, name)
def __init__(self, name, level=logging.NOTSET): return OriginalLogger.__init__(self, name, level)
def __init__(self, name='', *args, **kwargs): _Logger.__init__(self, name, *args, **kwargs)
def __init__(self, args={}): Logger.__init__(self, args['level'])
def __init__(self, name, level=NOTSET): Logger.__init__(self, name, level)