Пример #1
0
        static void Main(string[] args)
        {
            var detail = GetLogDetail("Starting Performance ", null);

            _perfTracker = new PerfTracker("SLoggerConsole_Execution", null, detail.UserName,
                                           detail.Location, detail.Product, detail.Layer);

            // create perf logger
            SLogger.WritePerformance(detail);

            SLogger.WriteDiagnostics(detail);

            SLogger.WriteUsage(detail);

            try
            {
                var ex = new Exception("Something bad happened.");
                ex.Data.Add("input param", "nothing to see here");
                throw ex;
            } catch (Exception ex)
            {
                SLogger.WriteError(GetLogDetail("", ex));
            }

            _perfTracker.Stop();
        }
Пример #2
0
        static void Main(string[] args)
        {
            var logDetails = GetSLogDetails("Starting Application", null);

            SLogger.WriteDiagnostic(logDetails);

            try
            {
                var ex = new Exception("Something bad has happend!");
                ex.Data.Add("input param", "nothing to see here");

                throw ex;
            }
            catch (Exception ex)
            {
                logDetails = GetSLogDetails("", ex);
                SLogger.WriteError(logDetails);
            }

            logDetails = GetSLogDetails("Used SLogging.Console application", null);
            SLogger.WriteUsage(logDetails);

            logDetails = GetSLogDetails("Stoping Application", null);
            SLogger.WriteDiagnostic(logDetails);
        }
        public override void Log(ExceptionLoggerContext context)
        {
            var logentry = new SLogDetail()
            {
                CorrelationId = new Guid().ToString(),
                Product       = _productName,
                Layer         = "API",
                Location      = context.Request.RequestUri.AbsoluteUri,
                Hostname      = Environment.MachineName,
                Exception     = context.Exception,
                UserName      = "******"
            };

            SLogger.WriteError(logentry);
            base.Log(context);
        }
Пример #4
0
        public static int Main(string[] args)
        {
            try
            {
                Arguments = new Docopt().Apply(Properties.Resources.cmd_schema, args, true, VERSION, false, true);

                Logger = new SLogger(Arguments["--silent"].IsTrue, Arguments["--verbose"].IsTrue);
            }
            catch (Exception e)
            {
                Console.Error.WriteLine($"Error during Initialization:\n{e}");
                return(-1);
            }

            try
            {
                if (Arguments["wol"].IsTrue)
                {
                    return(new WakeOnLANTask().Run());
                }
                if (Arguments["getmac"].IsTrue)
                {
                    return(new GetMACTask().Run());
                }
                if (Arguments["getip"].IsTrue)
                {
                    return(new GetIPTask().Run());
                }
                if (Arguments["ping"].IsTrue)
                {
                    return(new PingTask().Run());
                }
                if (Arguments["status"].IsTrue)
                {
                    return(new StatusTask().Run());
                }
                if (Arguments["status-all"].IsTrue)
                {
                    return(new StatusTask().Run());
                }
                if (Arguments["status-list"].IsTrue)
                {
                    return(new StatusListTask().Run());
                }
                if (Arguments["status"].IsTrue)
                {
                    return(new StatusTask().Run());
                }
                if (Arguments["shutdown"].IsTrue)
                {
                    return(new ShutdownTask().Run());
                }
                if (Arguments["reboot"].IsTrue)
                {
                    return(new RebootTask().Run());
                }
                if (Arguments["create-config"].IsTrue)
                {
                    return(new ConfigExampleTask(Arguments["<output_filename>"].Value?.ToString()).Run());
                }
            }
            catch (Exception e)
            {
                Logger.WriteError($"Internal error in program execution: {e.Message}", e);
                return(-1);
            }

            Logger.WriteError("No subcommand specified");
            return(-1);
        }