Пример #1
0
        public void writeToLog(string message, LogMessage.LogType type = LogMessage.LogType.INFO)
        {
            LogMessage msg = new LogMessage();

            msg.Message     = message;
            msg.MessageType = type;
            msg.ServiceName = serviceName;
            send(msg, Config.QueueName, Config.Url, false);
        }
Пример #2
0
        public void writeToLog(string message, LogMessage.LogType type = LogMessage.LogType.INFO)
        {
            LogMessage msg = new LogMessage();

            msg.Message     = message;
            msg.MessageType = type;
            msg.ServiceName = serviceName;

            ConnectionFactory conFactory = new ConnectionFactory(Config.Url);
            NmsTemplate       temp       = new NmsTemplate(conFactory);

            temp.Send(Config.QueueName, new GenericMessageCreator <LogMessage>(msg));
        }
Пример #3
0
        public void SendLogMessage(string logMsg, LogMessage.LogType logType = LogMessage.LogType.SYSTEM)
        {
            var logMessage            = new LogMessage(logMsg, logType);
            var lastMessageOfSameKind =
                Storage.LogMessages.FirstOrDefault(x => x.Value.TimeSent.AddSeconds(1) > DateTime.Now && x.Value.Key == logMsg);

            if (lastMessageOfSameKind.Value != null)
            {
                return;
            }
            if (Storage.LogMessages.TryAdd(Storage.LogMessages.Count, logMessage))
            {
                Packet.Builder.LegacyModule(World.StorageManager.GetGameSession(Id), "0|A|STM|" + logMsg + "");
            }
        }
Пример #4
0
        /// <summary>
        /// Get a report for all services in all folders.
        /// </summary>
        /// <returns>A dictionary mapping each folder name to an array of service reports for that folder.</returns>
        //public async Task<Dictionary<string, ServiceReport[]>> GetAllServiceReports()
        //{
        //    var folders = await GetFolderNames();

        //    var folderTasks = new Dictionary<string, Task<ServiceReport[]>>();

        //    folderTasks.Add("/", GetServiceReports());

        //    foreach (string folder in folders)
        //    {
        //        folderTasks.Add(folder, GetServiceReports(folder));
        //    }

        //    await Task.WhenAll(folderTasks.Values.ToArray());

        //    return folderTasks.ToDictionary(
        //        dict => { return dict.Key; },
        //        dict => { return dict.Value.Result; }
        //        );
        //}

        /// <summary>
        /// Get all log messages with a minimum log level within a certain date range (if specified).
        /// </summary>
        /// <param name="minimumLogLevel">The minimum log level of messages to return</param>
        /// <param name="startTime">The earliest time for which to return log entries.</param>
        /// <param name="endTime">The latest time for which to return log entries.</param>
        /// <returns>A list of LogMessage objects matching the specified log level and date range (if specified)</returns>
        public async Task <IEnumerable <LogMessage> > GetLogs(LogMessage.LogType minimumLogLevel, DateTime?startTime = null, DateTime?endTime = null)
        {
            var parms = new Dictionary <string, string>();

            parms["level"]  = minimumLogLevel.ToString().ToUpper();
            parms["filter"] = @"{""server"": ""*"", ""services"": ""*"", ""machines"":""*"" }"; // for now always request all servers, services, and machine
            if (startTime != null)
            {
                parms["startTime"] = EncodingHelper.GetUnixTimestampMillis(startTime.Value).ToString();
            }
            if (endTime != null)
            {
                parms["endTime"] = EncodingHelper.GetUnixTimestampMillis(endTime.Value).ToString();
            }

            Uri logEndpoint = new Uri(ServerUrl, "logs/query");

            LogQueryResponse response = await GetStringAsync <LogQueryResponse>(logEndpoint, parms);

            return(response.logMessages);
        }