Set log handler

If no hanlder given, we assume a sensible default

@param string $level Log level
@param  object $formatter Formatter intance
@return object
345107
public static function setHandler($level = null, $handler = null)
    {
        if (empty($level)) {
            $level = static::DEFAULT_LEVEL;
        }

        if (!empty($handler)) {
            static::$handler = $handler;
            return;
        }

        static::$handler = new \Monolog\Handler\StdoutHandler(constant("\Monolog\Logger::$level"));
        static::$handler->setFormatter(static::getFormatter());
    }
717454
public function setLevel(\n2n\log4php\LoggerLevel $level = null) {
		if (isset($level)) {
			parent::setLevel($level);
		} else {
			throw new \n2n\log4php\LoggerException("log4php: Cannot set LoggerRoot level to null.", E_USER_WARNING);
		}
	}
100974
public function setLevel(string $level)
    {
        if (!defined(LogLevel::class . '::' . strtoupper($level)))
            throw new \DomainException("Invalid log level: $level");

        $this->level = $level;
        $this->level_num = self::$LEVEL_NUMERIC[$level];
        return $this;
    }
411582
def set_logging_formatter(self):
        

        for handler in (RuntimeGlobals.logging_console_handler,
                        RuntimeGlobals.logging_file_handler,
                        RuntimeGlobals.logging_session_handler):
            handler and handler.setFormatter(
                RuntimeGlobals.logging_formatters[RuntimeGlobals.logging_active_formatter])
465693
public synchronized static void setFormatter(Formatter formatter) {
      java.util.logging.Logger root = java.util.logging.LogManager.getLogManager().getLogger(StringUtils.EMPTY);
      for (Handler h : root.getHandlers()) {
         h.setFormatter(formatter);
      }
   }
1144412
public function log($message, $level)
    {
        Injector::inst()->get(LoggerInterface::class)->log($level, $message);
    }
641051
def create_logger(name, formatter=None, handler=None, level=None):
    
    logger = logging.getLogger(name)

    #: remove existing handlers
    logger.handlers = []

    #: use a standard out handler
    if handler is None:
        handler = logging.StreamHandler(sys.stdout)

    #: set the formatter when a formatter is given
    if formatter is not None:
        handler.setFormatter(formatter)

    #: set DEBUG level if no level is specified
    if level is None:
        level = logging.DEBUG

    handler.setLevel(level)
    logger.setLevel(level)
    logger.addHandler(handler)
    return logger
78923
final protected static function callErrorLogger($level, $message)
	{
		if (is_null(static::$errorLoggerInstance)) {
			static::$errorLoggerInstance = new self;
		}
		static::$errorLoggerInstance->{
			static::$errorLoggerInstance->errorToLogLevel($level)
		}($message);
	}
283473
public function setLogger($logger = null)
    {

        if ($logger instanceOf \sb\Logger\Base) {
            $this->logger = $logger;
        } else {
            $this->logger = new \sb\Logger\FileSystem();
        }
    }
1220628
public function formatter($mode, $type, $handler = null)
    {
        if (func_num_args() === 2) {
          if (isset($this->_formatters[$mode][$type])) {
            return $this->_formatters[$mode][$type];
          } elseif (isset($this->_formatters[$mode]['_default_'])) {
            return $this->_formatters[$mode]['_default_'];
          } else {
            return;
          }
        }
        $this->_formatters[$mode][$type] = $handler;
        return $this;
    }
746811
protected function getStreamHandler(FormatterInterface $formatter, $stream, $level = Logger::DEBUG, $bubble = true)
    {
        // Unless cli, force output to php://output
        $stream = Director::is_cli() ? $stream : 'php://output';
        $handler = Injector::inst()->createWithArgs(
            StreamHandler::class,
            array($stream, $level, $bubble)
        );
        $handler->setFormatter($formatter);
        return $handler;
    }
433703
protected function setFormatter(FormatterInterface $formatter = null)
    {
        if ($this->color) {
            $this->formatter = new AnsiColorFormatter($formatter);
        } else {
            $this->formatter = $formatter;
        }
        return $this;
    }
719620
public function setFormatter(FormatterInterface $formatter, array $columns): self
    {
        $this->search()->in($columns)->setFormatter($formatter);

        return $this;
    }
659795
def set_logger(self, logger_name, level=logging.INFO):
        
        log = logging.getLogger(logger_name)
        log.setLevel(level)

        ch = logging.StreamHandler(None)
        ch.setLevel(level)

        # create formatter
        if level == logging.INFO:
            formatter = logging.Formatter(InfoFmtString)
        else:
            formatter = logging.Formatter(DebugFmtString)

        # add formatter to ch
        ch.setFormatter(formatter)

        # add ch to logger
        log.addHandler(ch)
1281260
private static function log(string $message, int $level) {
        \Logger::configure(self::getConfiguration());
        $logger = \Logger::getRootLogger();
        $logger->setLevel(self::getLoggerLevel());

        switch ($level) {
            case Logger::DEBUG:
                $logger->debug($message);
                break;
            case Logger::INFO:
                $logger->info($message);
                break;
            case Logger::WARN:
                $logger->warn($message);
                break;
            case Logger::ERROR:
                $logger->error($message);
                break;
            case Logger::FATAL:
                $logger->fatal($message);
                break;
            case Logger::TRACE:
                $logger->trace($message);
                break;
            default:
        }
    }
344150
public function setIndentLevel($level)
    {
        $level = intval($level);
        if (0 <= $level) {
            $this->_indentLevel = $level;
        }
        return $this;
    }
1006505
def _add_filehandler(logger, logpath, formatter=None, name="Bench"):
    
    formatter = formatter if formatter else BenchFormatterWithType(loggername=name)
    handler = _get_filehandler_with_formatter(logpath, formatter)
    config = LOGGING_CONFIG.get(name, {}).get("file", DEFAULT_LOGGING_CONFIG.get("file"))
    handler.setLevel(getattr(logging, config.get("level", "DEBUG")))
    logger.addHandler(handler)
    return logger