Print the start message to System.err with the time NOW, and register a
shutdown hook which will print the stop message to System.err with the
time then and the number of milliseconds passed since.
320238
private static void printStartStopTimes() {
        final long start = System.currentTimeMillis();

        System.err.println("Start at " + new Date());

        Thread hook = new Thread() {
            @Override
            public void run() {
                long timePassed = System.currentTimeMillis() - start;
                System.err.println("Stop at " + new Date() + ", execution time = " + timePassed + " ms");
            }
        };
        Runtime.getRuntime().addShutdownHook(hook);
    }
936041
@SuppressWarnings({"PMD.SystemPrintln"})
    public void printErrorMessage() {
        if (!quiet) {
            String msg = getCause().getMessage();
            System.err.println(getMessage() + " (command: " + command + ")" + (msg != null ? " : " + msg : ""));
        }
        if (verbose) {
            getCause().printStackTrace(System.err);
        }
    }
264186
def _start_timeout():
    """"""
    global _timeout

    LOGGER.debug('Adding a new timeout in %i ms', _timeout_interval)
    _maybe_stop_timeout()
    _timeout = ioloop.IOLoop.current().add_timeout(
        ioloop.IOLoop.current().time() + _timeout_interval / 1000.0,
        _on_timeout)
25744
public static void warn(String msg, Throwable t) {
        if (quietMode)
            return;

        System.err.println(WARN_PREFIX + msg);
        if (t != null) {
            t.printStackTrace();
        }
    }
538701
public synchronized void shutDown() {

        int count = 0;
        // if the handler is still running, we must wait up to 30 seconds until it is finished
        while ((count < HANDLER_FINISH_TIME) && m_handler.isBusy()) {
            count++;
            try {
                if (CmsLog.INIT.isInfoEnabled()) {
                    CmsLog.INIT.info(
                        Messages.get().getBundle().key(
                            Messages.INIT_STATIC_EXPORT_SHUTDOWN_3,
                            m_handler.getClass().getName(),
                            String.valueOf(count),
                            String.valueOf(HANDLER_FINISH_TIME)));
                }
                wait(1000);
            } catch (InterruptedException e) {
                // if interrupted we ignore the handler, this will produce some log messages but should be ok
                count = HANDLER_FINISH_TIME;
            }
        }

        if (CmsLog.INIT.isInfoEnabled()) {
            CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_SHUTDOWN_1, this.getClass().getName()));
        }

    }
1076207
private void shutdownImpl(ShutdownModeAmp mode, 
                            ExitCode exitCode,
                            Result<String> result)
  {
    // start the fail-safe thread in case the shutdown fails
    FailSafeHaltThread haltThread = _failSafeHaltThread;
    
    if (haltThread != null) {
      haltThread.startShutdown();
    }

    if (exitCode == null) {
      exitCode = ExitCode.FAIL_SAFE_HALT;
    }
    
    _exitCode.compareAndSet(null, exitCode);

    try {
      SystemManager systemManager = _systemManagerRef.get();
        
      if (systemManager != null) {
        systemManager.shutdown(mode);
      }
    } catch (Throwable e) {
      log.log(Level.WARNING, e.toString(), e);
    } finally {
      _systemManagerRef = null;
      _lifecycle.toDestroy();

      System.err.println("\nShutdown reason: " + exitCode + "\n");

      log.warning("Shutdown reason: " + exitCode);
      
      if (result != null) {
        result.ok("Shutdown reason: " + exitCode);
      }

      if (! _isEmbedded) {
        System.exit(exitCode.ordinal());
      }
    }
  }
819597
def fail(message, exception_data=None):
  
  print(message, file=sys.stderr)
  if exception_data:
    print(repr(exception_data))
  sys.exit(1)
1329153
def shutdown(self, join=True, timeout=None):
        
        if self.is_alive():  # check if process started
            print("Shutdown initiated")
            self.exit.set()
            if join:
                self.join(timeout=timeout)
                # TODO : timeout before forcing terminate (SIGTERM)

        exitcode = self._process.exitcode if self._process else None  # we return None if the process was never started
        return exitcode
1113643
public static function shutdown()
    {
        if (defined('__TIMER_OUT_FILE__')) {
            $strTimerOutput = Timer::varDump(false);
            if ($strTimerOutput) {
                file_put_contents(__TIMER_OUT_FILE__, $strTimerOutput . "\n", FILE_APPEND);
            }
        }

        $error = error_get_last();
        if ($error &&
            is_array($error) &&
            (!defined('\CodeGen::DebugMode') || \CodeGen::DebugMode)
        ) { // if we are codegenning, only error if we are in debug mode. Prevents chmod error.

            QcubedHandleError(
                $error['type'],
                $error['message'],
                $error['file'],
                $error['line'],
                ''
            );
        }
        //flush();	// required for hhvm
        //error_log("Flushed");
    }
908979
def print_error(self, error):
        
        print(colored(error.message, 'red'), file=self.stderr)

        if error.stdout or error.stderr:
            print(file=self.stderr)
            print("Here's what git said:", file=self.stderr)
            print(file=self.stderr)

            if error.stdout:
                print(error.stdout, file=self.stderr)
            if error.stderr:
                print(error.stderr, file=self.stderr)

        if error.details:
            print(file=self.stderr)
            print("Here's what we know:", file=self.stderr)
            print(str(error.details), file=self.stderr)
            print(file=self.stderr)
420567
public static void startDoing(String str) {
    System.err.print(str);
    System.err.print(" ... ");
    System.err.flush();
    startTime();
  }
3399
def error(self, message):
        
        self.print_usage(_sys.stderr)
        self.exit(2, _('%s: error: %s\n') % (self.prog, message))
711346
public void shutdown(ShutdownModeAmp mode,
                       ExitCode exitCode, 
                       String msg,
                       Result<String> result)
  {
    startFailSafeShutdown(msg);

    ShutdownThread shutdownThread = _shutdownThread;
    
    if (shutdownThread != null) {
      shutdownThread.startShutdown(mode, exitCode, result);

      if (! _isEmbedded) {
        waitForShutdown();
      
        System.out.println("Shutdown timeout");
        System.exit(exitCode.ordinal());
      }
    }
    else {
      shutdownImpl(mode, exitCode, result);
    }
  }
1193618
def print_err(self, *lst):
      
      self.print2file(self.stderr, False, True, *lst)
642654
public static function shutdownHandler()
    {
        if ( ! ($error = error_get_last())) {
            return;
        }

        self::exceptionHandler(
            new \ErrorException($error['message'], 0, $error['type'], $error['file'], $error['line'])
        );
    }
1208763
def _print_debug(self, *args):
        
        if self.debuglevel > 1:
            print(datetime.datetime.now().time(), *args, file=sys.stderr)
        else:
            print(*args, file=sys.stderr)
38743
def print_time(self, message="Time is now: ", print_frame_info=True):
        
        if print_frame_info:
            frame_info = inspect.getouterframes(inspect.currentframe())[1]
            print(message, (datetime.now() - self.start_time), frame_info)
        else:
            print(message, (datetime.now() - self.start_time))