コード例 #1
0
 private static void LogResponse(Logger logger, LogCommandResponse response)
 {
     logger.LogInfo("[LOG]  {0} {1} ({2})\t{3}", response.Time, response.LogId, response.Source,
                    response.Message);
 }
コード例 #2
0
        private void processResponse(byte[] data)
        {
            if (data == null)
            {
                return;
            }
            string             message            = Encoding.UTF8.GetString(data, 0, data.Length);
            LogCommandResponse logCommandResponse = JsonConvert.DeserializeObject <LogCommandResponse>(message);

            switch (logCommandResponse.command)
            {
            case LogCommand.COMMAND_PROBE_RESPONSE:
            {
                string contextName = logCommandResponse.contextName;
                Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                    {
                        if (!ServicesList.Contains(contextName))
                        {
                            ServicesList.Add(contextName);
                        }
                        logCommandResponse.probeLoggers?.ForEach(p =>
                        {
                            //if (!p.loggerName.StartsWith("com.yyn"))
                            //{
                            //    return;
                            //}
                            p.contextName = contextName;
                            {
                                Logger existLogger = LoggerList.FirstOrDefault((loggerInList) =>
                                {
                                    if (String.Equals(p.contextName, loggerInList.contextName) && String.Equals(p.loggerName, loggerInList.loggerName))
                                    {
                                        return(true);
                                    }
                                    return(false);
                                });
                                if (existLogger == null)
                                {
                                    p.setLoggerLevel = p.loggerLevel;
                                    LoggerList.Add(p);
                                }
                                else
                                {
                                    if (existLogger.loggerLevel != p.loggerLevel || existLogger.setLoggerLevel != p.setLoggerLevel)
                                    {
                                        existLogger.loggerLevel    = p.loggerLevel;
                                        existLogger.setLoggerLevel = p.setLoggerLevel;
                                        ConfigLoggerWindow.refreshList();
                                    }
                                }
                                if (p.configured)
                                {
                                    addToModifiedProbeLoggerList(p);
                                }
                            }
                        });
                    }), null);
            }
            break;

            case LogCommand.COMMAND_PROBE_SERVICE_RESPONSE:
            {
                ProbeServiceResponse probeServiceResponse = JsonConvert.DeserializeObject <ProbeServiceResponse>(message);
                string contextName = probeServiceResponse.contextName;
                if (!String.IsNullOrEmpty(probeServiceResponse.contextName))
                {
                    Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                        {
                            if (!ServicesList.Contains(contextName))
                            {
                                ServicesList.Add(contextName);
                            }
                        }), null);
                }
            }
            break;

            case LogCommand.COMMAND_LOG_OUTPUT:
            {
                MainWindow.AppendMessageStatic(logCommandResponse.mesasge);
            }
            break;
            }
        }