Ejemplo n.º 1
0
        internal void Register(LogAdapter Log)
        {
            if (SignalLogger.registered)
            {
                throw new InvalidOperationException("Can't re-install the signal handlers.");
            }
            SignalLogger.registered = true;
            StringBuilder bld = new StringBuilder();

            bld.Append("registered UNIX signal handlers for [");
            string[] Signals   = new string[] { "TERM", "HUP", "INT" };
            string   separator = string.Empty;

            foreach (string signalName in Signals)
            {
                try
                {
                    new SignalLogger.Handler(signalName, Log);
                    bld.Append(separator);
                    bld.Append(signalName);
                    separator = ", ";
                }
                catch (Exception e)
                {
                    Log.Debug(e);
                }
            }
            bld.Append("]");
            Log.Info(bld.ToString());
        }
Ejemplo n.º 2
0
        internal static void StartupShutdownMessage(Type clazz, string[] args, LogAdapter
                                                    Log)
        {
            string hostname  = NetUtils.GetHostname();
            string classname = clazz.Name;

            Log.Info(ToStartupShutdownString("STARTUP_MSG: ", new string[] { "Starting " + classname
                                                                             , "  host = " + hostname, "  args = " + Arrays.AsList(args), "  version = " + VersionInfo
                                                                             .GetVersion(), "  classpath = " + Runtime.GetProperty("java.class.path"), "  build = "
                                                                             + VersionInfo.GetUrl() + " -r " + VersionInfo.GetRevision() + "; compiled by '"
                                                                             + VersionInfo.GetUser() + "' on " + VersionInfo.GetDate(), "  java = " + Runtime
                                                                             .GetProperty("java.version") }));
            if (SystemUtils.IsOsUnix)
            {
                try
                {
                    SignalLogger.Instance.Register(Log);
                }
                catch (Exception t)
                {
                    Log.Warn("failed to register any UNIX signal loggers: ", t);
                }
            }
            ShutdownHookManager.Get().AddShutdownHook(new _Runnable_673(Log, classname, hostname
                                                                        ), ShutdownHookPriority);
        }