public bool Accepted(EventWriterTriplet writerTriplet, LoggerEvent loggerEvent, string message) { var newMessage = loggerEvent.Properties[LoggerEvent.MESSAGE_PROPERTY].ToString(); bool asseptResult = false; if (!loggerEvent.Properties.ContainsKey(BpcLoggerExtensions.MESSAGEID_PROPERTY)) { asseptResult = true; } else if (!_filteredTypes.Contains((Message)loggerEvent.Properties[BpcLoggerExtensions.MESSAGEID_PROPERTY])) { asseptResult = true; } else if (writerTriplet.Raw) { newMessage = string.Format(newMessage, (object[])loggerEvent[LoggerEvent.PARAMETERS_PROPERTY]); asseptResult = _lastMessageText != newMessage; } else if (!writerTriplet.Raw && _lastMessageText != newMessage) { asseptResult = true; } _lastMessageText = newMessage; return(asseptResult); }
public bool Accepted(EventWriterTriplet writerTriplet, LoggerEvent loggerEvent, string message) { Console.WriteLine("EventWriterFilter.Accepted({0}, {1})", loggerEvent.Id, message); return(true); }
public bool Accepted(EventWriterTriplet writerTriplet, LoggerEvent loggerEvent, string message) { Console.WriteLine("EventWriterFilter.Accepted({0}, {1})", loggerEvent.Id, message); return true; }
public bool Accepted(EventWriterTriplet writerTriplet, LoggerEvent logEvent, string message) { if (!(writerTriplet.Writer is IEventFileSystemWriter)) { return(true); } string uniqueId = EventDispatcher.GetUniqueId(logEvent); if (_blockedLogs.Contains(uniqueId)) { return(false); } var pointName = DEFAULT_LOG_NAME; if (EventDispatcher.GroupByFieldDefined && logEvent.Properties.ContainsKey(EventDispatcher.GroupByField)) { var groupByFieldValue = (string)logEvent[EventDispatcher.GroupByField]; if (_minFreeSpaces.ContainsKey(groupByFieldValue)) { pointName = groupByFieldValue; } } var minFreeSpace = _minFreeSpaces[pointName]; var requiredSize = message.Length / FileUtils.BYTES_IN_KB + 1; long availableSize; var fileSystemManager = GetFileSystemManager(); if (fileSystemManager != null && !fileSystemManager.ReserveDiskSpace( (writerTriplet.Writer as IEventFileSystemWriter).GetPoint(uniqueId), requiredSize, minFreeSpace, out availableSize)) { var errorEvent = new LoggerEvent { EventType = TraceEventType.Error }; errorEvent[LoggerEvent.LOGGERNAME_PROPERTY] = logEvent[LoggerEvent.LOGGERNAME_PROPERTY]; errorEvent[BpcLoggerExtensions.MESSAGEID_PROPERTY] = Message.Common_AvailableSpaceFilterNotEnoughSpaceError; var minSizeMb = (double)minFreeSpace / FileUtils.BYTES_IN_KB; var availableSizeMb = (double)availableSize / FileUtils.BYTES_IN_MB; if (writerTriplet.Raw) { errorEvent[LoggerEvent.MESSAGE_PROPERTY] = Message.Common_AvailableSpaceFilterNotEnoughSpaceError; errorEvent[LoggerEvent.PARAMETERS_PROPERTY] = new object[] { uniqueId, availableSizeMb, minSizeMb }; } else { errorEvent[LoggerEvent.MESSAGE_PROPERTY] = string.Format( BpcLoggerExtensions.GetMessageBody(Message.Common_AvailableSpaceFilterNotEnoughSpaceError), uniqueId, availableSizeMb, minSizeMb); } writerTriplet.Writer.Write(uniqueId, writerTriplet.Formatter.Format(errorEvent)); if (!_blockedLogs.Contains(uniqueId)) { _blockedLogs.Add(uniqueId); } return(false); } return(true); }