/*
Initial logging.
501127
function () {
    log();
    log('source', fss.baseRelative(config.source));
    log('target', fss.baseRelative(config.target));
    if (!fss.directoryExists(fss.baseRelative(config.appdir))) {
        log('error', 'no source directory at', config.appdir);
        process.exit(1);
    }
}
1346602
def LogInit():
  """"""
  logging.debug("Initializing client logging subsystem.")

  # The root logger.
  logger = logging.getLogger()
  memory_handlers = [
      m for m in logger.handlers
      if m.__class__.__name__ == "PreLoggingMemoryHandler"
  ]

  # Clear all handers.
  logger.handlers = list(GetLogHandlers())
  SetLogLevels()

  # Now flush the old messages into the log files.
  for handler in memory_handlers:
    for record in handler.buffer:
      logger.handle(record)
1369490
def initialize(self):
        """"""

        self.logger = logging.getLogger(self.__class__.__name__)
        self.client = None
453621
private static void initLogger(SourceState state) {
    StringBuilder sb = new StringBuilder();
    sb.append("[");
    sb.append(StringUtils.stripToEmpty(state.getProp(ConfigurationKeys.SOURCE_QUERYBASED_SCHEMA)));
    sb.append("_");
    sb.append(StringUtils.stripToEmpty(state.getProp(ConfigurationKeys.SOURCE_ENTITY)));
    sb.append("]");
    MDC.put("sourceInfo", sb.toString());
  }
479941
protected void initLogger(SourceState state) {
    StringBuilder sb = new StringBuilder();
    sb.append("[");
    sb.append(Strings.nullToEmpty(state.getProp(ConfigurationKeys.SOURCE_ENTITY)));
    sb.append("]");
    MDC.put("sourceInfo", sb.toString());
  }
550464
@Override
    protected void doStart() {
        log.info("{}: Starting.", this.traceObjectId);

        Services.startAsync(this.durableLog, this.executor)
                .thenComposeAsync(v -> startWhenDurableLogOnline(), this.executor)
                .whenComplete((v, ex) -> {
                    if (ex == null) {
                        // We are started and ready to accept requests when DurableLog starts. All other (secondary) services
                        // are not required for accepting new operations and can still start in the background.
                        notifyStarted();
                    } else {
                        doStop(ex);
                    }
                });
    }
1010250
@Override
    protected void onInit() {
        logger.info("DoTaskApp onInit");
        // ConsoleReporters prints S4 metrics
        // MetricsRegistry mr = new MetricsRegistry();
        //
        // CsvReporter.enable(new File(System.getProperty("user.home")
        // + "/monitor/"), 10, TimeUnit.SECONDS);
        // ConsoleReporter.enable(10, TimeUnit.SECONDS);
        try {
            System.err.println();
            System.err.println(Globals.getWorkbenchInfoString());
            System.err.println();

        } catch (Exception ex) {
            ex.printStackTrace();
        }
        S4ComponentFactory factory = new S4ComponentFactory();
        factory.setApp(this);

        // logger.debug("LC {}", lc);

        // task = TaskProvider.getTask(evalTask);

        // EXAMPLE OPTIONS
        // -l Clustream -g Clustream -i 100000 -s (RandomRBFGeneratorEvents -K
        // 5 -N 0.0)
        // String[] args = new String[] {evalTask,"-l", "Clustream","-g",
        // "Clustream", "-i", "100000", "-s", "(RamdomRBFGeneratorsEvents",
        // "-K", "5", "-N", "0.0)"};
        // String[] args = new String[] { evalTask, "-l", "clustream.Clustream",
        // "-g", "clustream.Clustream", "-i", "100000", "-s",
        // "(RandomRBFGeneratorEvents", "-K", "5", "-N", "0.0)" };
        logger.debug("PARAMETERS {}", evalTask);
        // params = params.replace(":", " ");
        List<String> parameters = new ArrayList<String>();
        // parameters.add(evalTask);
        try {
            parameters.addAll(Arrays.asList(URLDecoder.decode(evalTask, "UTF-8").split(" ")));
        } catch (UnsupportedEncodingException ex) {
            ex.printStackTrace();
        }
        String[] args = parameters.toArray(new String[0]);
        Option[] extraOptions = new Option[] {};
        // build a single string by concatenating cli options
        StringBuilder cliString = new StringBuilder();
        for (int i = 0; i < args.length; i++) {
            cliString.append(" ").append(args[i]);
        }

        // parse options
        try {
            task = (Task) ClassOption.cliStringToObject(cliString.toString(), Task.class, extraOptions);
            task.setFactory(factory);
            task.init();
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
555080
public function init()
	{
		parent::init();

		if($this->autoCreateLogTable)
		{
			$db=$this->getDbConnection();
			try
			{
				$db->createCommand()->delete($this->logTableName,'0=1');
			}
			catch(Exception $e)
			{
				$this->createLogTable($db,$this->logTableName);
			}
		}
	}
772304
private synchronized void defaultInit() 
    {
        if (!_initialized)
        {
            _initialized = true;
            String sinkClasses = System.getProperty("LOG_SINKS","org.browsermob.proxy.jetty.log.OutputStreamLogSink");
            StringTokenizer sinkTokens = new StringTokenizer(sinkClasses, ";, ");
                    
            LogSink sink= null;
            while (sinkTokens.hasMoreTokens())
            {
                String sinkClassName = sinkTokens.nextToken();
                    	
                try
                {
                    Class sinkClass = Loader.loadClass(this.getClass(),sinkClassName);
                    if (org.browsermob.proxy.jetty.log.LogSink.class.isAssignableFrom(sinkClass)) {
                        sink = (LogSink)sinkClass.newInstance();
                        sink.start();
                        add(sink);
                    }
                    else
                        // Can't use Code.fail here, that's what we're setting up
                        System.err.println(sinkClass+" is not a org.browsermob.proxy.jetty.log.LogSink");
                }
                catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
    }
542068
private void initOut() throws IOException
   {
      if (out == null)
      {
         FileOutputStream os = PrivilegedFileHelper.fileOutputStream(logFile, false);
         out = os.getChannel();
      }
   }
273763
protected function init() : void
    {
        if ($this->initialized) {
            return;
        }
        $this->initialized = true;
        $this->log("Daemon Initialized", LOG_INFO, [ "syslog", STDOUT ], true);
    }
1123239
def __finish_initializing(self):
        

        if self.args.debug or self.args.trace:
            # Set the console (StreamHandler) to allow debug statements.

            if self.args.debug:
                self.console.setLevel(logging.DEBUG)

            self.console.setFormatter(logging.Formatter('[%(levelname)s] %(asctime)s %(name)s - %(message)s'))

            # Set the global level to debug.
            if self.args.debug:
                self.log.setLevel(logging.DEBUG)

        if self.args.log or self.log_file:

            # Allow the user to override the default log file handler.
            try:
                self.log_file_handler = sys.modules['__main__'].log_file_handler(self.args.log or self.log_file)
            except Exception:
                self.log_file_handler = logging.FileHandler(self.args.log or self.log_file)

            self.log_file_handler.setFormatter(logging.Formatter('[%(levelname)s] %(asctime)s %(name)s - %(message)s'))
            self.log_file_handler.setLevel(logging.DEBUG)

            self.log.addHandler(self.log_file_handler)

        # Allow cli.log, args & self to be accessed from __main__
        if not hasattr(sys.modules['__main__'], 'log'):
            sys.modules['__main__'].log = self.log

        if not hasattr(sys.modules['__main__'], 'cli'):
            sys.modules['__main__'].cli = self

        if not hasattr(sys.modules['__main__'], 'args'):
            sys.modules['__main__'].args = self.args
1051971
private static function init() {
        if (self::$logDebug === null) {
            $loglevel        = Logger::getLogLevel(__CLASS__);
            self::$logDebug  = ($loglevel <= L_DEBUG );
            self::$logInfo   = ($loglevel <= L_INFO  );
            self::$logNotice = ($loglevel <= L_NOTICE);
        }
    }
1088989
@Override
  protected void setupLogging(@Nullable final Level level) {
    TargetConsoleAppender.setTarget(System.out);

    // adapt configuration properties for logging unless already set
    if (level != null) {
      maybeSetProperty("shell.logging.console.threshold", level.name());
      maybeSetProperty("shell.logging.file.threshold", level.name());
      maybeSetProperty("shell.logging.root-level", level.name());
    }

    super.setupLogging(level);
  }
364363
@Subscribe
  public void onStart(AggregatedStartEvent e) throws IOException {
    this.totalSuites = e.getSuiteCount();
    logShort("Executing " +
        totalSuites + Pluralize.pluralize(totalSuites, " suite") +
        " with " + 
        e.getSlaveCount() + Pluralize.pluralize(e.getSlaveCount(), " JVM") + ".\n", false);

    forkedJvmCount = e.getSlaveCount();
    jvmIdFormat = " J%-" + (1 + (int) Math.floor(Math.log10(forkedJvmCount))) + "d";

    outWriter = new PrefixedWriter(stdoutIndent, output, DEFAULT_MAX_LINE_WIDTH);
    errWriter = new PrefixedWriter(stderrIndent, output, DEFAULT_MAX_LINE_WIDTH);        
  }
325491
public static void loggerInit(Level level, boolean isRedirectStdOutErr, String format)
      throws IOException {
    // Set the java util logging format
    setLoggingFormat(format);

    // Configure the root logger and its handlers so that all the
    // derived loggers will inherit the properties
    Logger rootLogger = Logger.getLogger("");
    for (Handler handler : rootLogger.getHandlers()) {
      handler.setLevel(level);
    }

    rootLogger.setLevel(level);

    if (rootLogger.getLevel().intValue() < Level.WARNING.intValue()) {
      // zookeeper logging scares me. if people want this, we can patch to config-drive this
      Logger.getLogger("org.apache.zookeeper").setLevel(Level.WARNING);
    }

    // setting logging for http client to be error level
    System.setProperty(
        "org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");
    System.setProperty(
        "org.apache.commons.logging.simplelog.log.httpclient.wire", "ERROR");
    System.setProperty(
        "org.apache.commons.logging.simplelog.log.org.apache.http", "ERROR");
    System.setProperty(
        "org.apache.commons.logging.simplelog.log.org.apache.http.headers", "ERROR");

    if (isRedirectStdOutErr) {

      // Remove ConsoleHandler if present, to avoid StackOverflowError.
      // ConsoleHandler writes to System.err and since we are redirecting
      // System.err to Logger, it results in an infinite loop.
      for (Handler handler : rootLogger.getHandlers()) {
        if (handler instanceof ConsoleHandler) {
          rootLogger.removeHandler(handler);
        }
      }

      // now rebind stdout/stderr to logger
      Logger logger;
      LoggingOutputStream los;

      logger = Logger.getLogger("stdout");
      los = new LoggingOutputStream(logger, StdOutErrLevel.STDOUT);
      System.setOut(new PrintStream(los, true));

      logger = Logger.getLogger("stderr");
      los = new LoggingOutputStream(logger, StdOutErrLevel.STDERR);
      System.setErr(new PrintStream(los, true));
    }
  }
1078275
public function init() {

        $args = $this->console->arguments;

        $args->parse();

        if ( $args->defined('hardstart') ) {

            $this->hardstart();

        }

        if ( $args->defined('daemon') ) {

            $this->daemonize();

        } else if ( $args->defined('foreground') ) {

            if ( $args->defined('verbose') ) {
                $this->logger->pushHandler(new LogHandler());
            }

            $this->start();

        } else {

            $this->console->pad()->green()->usage();
            $this->end(0);

        }

    }