IPostprocessorRunSummary IPostprocessorRunSummary.GetLogSpecificSummary(ILogSource ls)
        {
            IPostprocessorRunSummary ret;

            innerSummaries.TryGetValue(ls, out ret);
            return(ret);
        }
Beispiel #2
0
 public LogSourceInfo(ILogSource source, string name, bool autoScroll, bool collectStatsOnDemand)
 {
     this.CollectStatsOnDemand = collectStatsOnDemand;
     this.AutoScroll = autoScroll;
     this.Name = name;
     this.Source = source;
 }
Beispiel #3
0
	public static void Err(ILogSource loggr, RestServiceException ex)
	{
		bool showInnerException = true;
		string msg = ""; switch (ex.Code)
		{
			case HttpStatusCode.NotAcceptable:
				msg = "Invalid JSON object format.";
				showInnerException = false;
				break;

			case HttpStatusCode.Conflict:
				msg = "Value already exists in the database.";
				break;

			case HttpStatusCode.BadRequest:
				msg = "Unrecognized data fields.";
				break;

			case HttpStatusCode.Forbidden:
				var usr = ex.InnerException.Message.Between("Access denied for user ", ").", true);
				msg = "{0} is not allowed to create new nodes.".f(usr.Quotify());
				showInnerException = false;
				break;
		}

		OnAnyEvent.Error(loggr, ex, msg, showInnerException);
	}
 /// <summary>
 ///     Creates a filtered view onto this log file.
 /// </summary>
 /// <param name="logSource"></param>
 /// <param name="scheduler"></param>
 /// <param name="logLineFilter"></param>
 /// <param name="logEntryFilter"></param>
 /// <returns></returns>
 internal static FilteredLogSource AsFiltered(this ILogSource logSource,
                                              ITaskScheduler scheduler,
                                              ILogLineFilter logLineFilter,
                                              ILogEntryFilter logEntryFilter)
 {
     return(AsFiltered(logSource, scheduler, logLineFilter, logEntryFilter, TimeSpan.FromMilliseconds(value: 10)));
 }
 void OnLogLine(ILogSource sender, string message, LogLevel visibility)
 {
     if (LogLine != null)
     {
         LogLine(sender, message, visibility);
     }
 }
        public static IReadOnlyLogBuffer GetEntries(this ILogSource logSource, IReadOnlyList <LogLineIndex> sourceIndices, IEnumerable <IColumnDescriptor> columns)
        {
            var buffer = new LogBufferArray(sourceIndices.Count, columns);

            logSource.GetEntries(sourceIndices, buffer);
            return(buffer);
        }
        public static IReadOnlyLogEntry GetEntry(this ILogSource logSource, LogLineIndex sourceIndex, IEnumerable <IColumnDescriptor> columns)
        {
            var buffer = new LogBufferArray(1, columns);

            logSource.GetEntries(new LogSourceSection(sourceIndex, 1), buffer);
            return(buffer[0]);
        }
        public static IReadOnlyLogBuffer GetEntries(this ILogSource logSource, IReadOnlyList <LogLineIndex> sourceIndices)
        {
            var buffer = new LogBufferArray(sourceIndices.Count, logSource.Columns);

            GetEntries(logSource, sourceIndices, buffer);
            return(buffer);
        }
        /// <summary>
        ///     Returns all properties from this log file.
        /// </summary>
        /// <returns></returns>
        public static IPropertiesBuffer GetAllProperties(this ILogSource that)
        {
            var destination = new PropertiesBufferList();

            that.GetAllProperties(destination);
            return(destination);
        }
        void SaveLogSourceAsInternal(ILogSource logSource)
        {
            ISaveAs saveAs = logSource.Provider as ISaveAs;

            if (saveAs == null || !saveAs.IsSavableAs)
            {
                return;
            }
            string filename = fileDialogs.SaveFileDialog(new SaveFileDialogParams()
            {
                SuggestedFileName = saveAs.SuggestedFileName ?? "log.txt"
            });

            if (filename == null)
            {
                return;
            }
            try
            {
                saveAs.SaveAs(filename);
            }
            catch (Exception ex)
            {
                alerts.ShowPopup("Error", "Failed to save file: " + ex.Message, AlertFlags.Ok | AlertFlags.WarningIcon);
            }
        }
        void IViewEvents.OnMenuItemOpening(bool ctrl, out MenuItem visibleItems, out MenuItem checkedItems)
        {
            visibleItems = MenuItem.None;
            checkedItems = MenuItem.None;
            ILogSource s = GetLogSource();

            if (s != null)
            {
                visibleItems |= (MenuItem.SourceVisible | MenuItem.SourceProprties);
                if ((s.Provider is ISaveAs) && ((ISaveAs)s.Provider).IsSavableAs)
                {
                    visibleItems |= MenuItem.SaveLogAs;
                }
                if (logSourcesPreprocessings.ExtractUserBrowsableFileLocationFromConnectionParams(s.Provider.ConnectionParams) != null)
                {
                    visibleItems |= MenuItem.OpenContainingFolder;
                }
                if (s.Visible)
                {
                    checkedItems |= MenuItem.SourceVisible;
                }
            }
            if (GetSelectedItems().Any(i => (i.Datum as PreprocessingItemData)?.Preprocessing?.Failure != null))
            {
                visibleItems |= MenuItem.CopyErrorMessage;
            }

            int totalSourcesCount  = 0;
            int visibeSourcesCount = 0;

            foreach (var ls in logSources.Items)
            {
                ++totalSourcesCount;
                if (ls.Visible)
                {
                    visibeSourcesCount++;
                }
            }

            bool saveMergedLogFeatureEnabled = true;

            if (saveMergedLogFeatureEnabled && visibeSourcesCount >= 2)
            {
                visibleItems |= (MenuItem.SaveMergedFilteredLog | MenuItem.Separator1);
            }

            if (totalSourcesCount > 1 && GetLogSource() != null)
            {
                visibleItems |= (MenuItem.ShowOnlyThisLog | MenuItem.CloseOthers);
            }
            if (visibeSourcesCount != totalSourcesCount)
            {
                visibleItems |= MenuItem.ShowAllLogs;
            }

            if (visibleItems == (MenuItem.SaveMergedFilteredLog | MenuItem.Separator1))
            {
                visibleItems = MenuItem.SaveMergedFilteredLog;                 // hide unneeded separator
            }
        }
Beispiel #12
0
 public RootView(ILogSource <T> logSource, IFilter filter) : base(
         $"{logSource.Name}{(filter != null ? $" ({filter.Name})" : null)}{(logSource.Properties.DynamicLoadingEnabled ? " (AutoLoad)" : null)}{(logSource.Properties.CompressEnabled ? " (Compressed)" : null)}")
 {
     this.Source       = logSource;
     this.Filter       = filter;
     this.GroupFilters = logSource.GroupFilters;
 }
Beispiel #13
0
 public LogSourceInfo(ILogSource source, string name, bool autoScroll, bool collectStatsOnDemand)
 {
     this.CollectStatsOnDemand = collectStatsOnDemand;
     this.AutoScroll           = autoScroll;
     this.Name   = name;
     this.Source = source;
 }
Beispiel #14
0
 void ILogSourcesManagerInternal.OnSourceAnnotationChanged(ILogSource t)
 {
     if (OnLogSourceAnnotationChanged != null)
     {
         OnLogSourceAnnotationChanged(t, EventArgs.Empty);
     }
 }
Beispiel #15
0
        public static void Err(ILogSource loggr, RestServiceException ex)
        {
            bool   showInnerException = true;
            string msg = ""; switch (ex.Code)

            {
            case HttpStatusCode.NotAcceptable:
                msg = "Invalid JSON object format.";
                showInnerException = false;
                break;

            case HttpStatusCode.Conflict:
                msg = "Value already exists in the database.";
                break;

            case HttpStatusCode.BadRequest:
                msg = "Unrecognized data fields.";
                break;

            case HttpStatusCode.Forbidden:
                var usr = ex.InnerException.Message.Between("Access denied for user ", ").", true);
                msg = "{0} is not allowed to create new nodes.".f(usr.Quotify());
                showInnerException = false;
                break;
            }

            OnAnyEvent.Error(loggr, ex, msg, showInnerException);
        }
Beispiel #16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LogMessage"/>.
 /// </summary>
 /// <param name="source">The log source.</param>
 /// <param name="time">Message creating time.</param>
 /// <param name="level">The level of the log message.</param>
 /// <param name="getMessage">The function returns the text for <see cref="LogMessage.Message"/>.</param>
 public LogMessage(ILogSource source, DateTimeOffset time, LogLevels level, Func <string> getMessage)
 {
     Source      = source ?? throw new ArgumentNullException(nameof(source));
     _getMessage = getMessage ?? throw new ArgumentNullException(nameof(getMessage));
     Time        = time;
     Level       = level;
 }
        public static IReadOnlyLogEntry GetEntry(this ILogSource logSource, LogLineIndex sourceIndex)
        {
            var buffer = new LogBufferArray(1, logSource.Columns);

            logSource.GetEntries(new LogSourceSection(sourceIndex, 1), buffer);
            return(buffer[0]);
        }
Beispiel #18
0
        public LogSourceSearch(ITaskScheduler taskScheduler, ILogSource logSource, string searchTerm, TimeSpan maximumWaitTime)
        {
            if (taskScheduler == null)
            {
                throw new ArgumentNullException(nameof(taskScheduler));
            }
            if (logSource == null)
            {
                throw new ArgumentNullException(nameof(logSource));
            }
            if (string.IsNullOrEmpty(searchTerm))
            {
                throw new ArgumentException("searchTerm may not be empty");
            }

            _logSource            = logSource;
            _filter               = new SubstringFilter(searchTerm, true);
            _matches              = new List <LogMatch>();
            _syncRoot             = new object();
            _listeners            = new LogFileSearchListenerCollection(this);
            _pendingModifications = new ConcurrentQueue <LogSourceModification>();
            _scheduler            = taskScheduler;

            const int maximumLineCount = 1000;

            _maximumWaitTime = maximumWaitTime;
            _logLinesArray   = new LogBufferArray(maximumLineCount, Columns.Index, Columns.RawContent);
            _matchesBuffer   = new List <LogLineMatch>();
            _logSource.AddListener(this, _maximumWaitTime, maximumLineCount);

            _task = _scheduler.StartPeriodic(FilterAllPending,
                                             TimeSpan.FromMilliseconds(100),
                                             string.Format("Search {0}", logSource));
        }
Beispiel #19
0
        protected override ParsingResult ParseSource(ILogSource source, LogReaderSettings settings, ParsingResult result = null)
        {
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }

            TextStorage storage = new TextStorage();

            result = result ?? new ParsingResult();
            var log = (IEnumerable <string[]>)source;

            if (!(source is AzureLogSource))
            {
                throw new ApplicationException("Non Azure log source was tried to be parsed by Azure log reader");
            }

            foreach (var lines in log)
            {
                var logEntry = logParser.ParseLine(lines[0], new DateTime(long.Parse(lines[1])), storage);
                if (logEntry != null)
                {
                    logEntry = AnalyzeLog(logEntry, storage);
                    result.AddToGroupAll(logEntry);
                }
            }
            return(result);
        }
Beispiel #20
0
 void ILogSourcesManagerInternal.OnSourceColorChanged(ILogSource logSource)
 {
     if (OnLogSourceColorChanged != null)
     {
         OnLogSourceColorChanged(logSource, EventArgs.Empty);
     }
 }
Beispiel #21
0
        /// <inheritdoc />
        public void GetColumn <T>(IReadOnlyList <LogLineIndex> sourceIndices, IColumnDescriptor <T> column, T[] destination, int destinationIndex, LogSourceQueryOptions queryOptions)
        {
            if (column == null)
            {
                throw new ArgumentNullException(nameof(column));
            }
            if (destination == null)
            {
                throw new ArgumentNullException(nameof(destination));
            }

            ILogSource logSource = _source;

            if (logSource != null)
            {
                logSource.GetColumn(sourceIndices, column, destination, destinationIndex, queryOptions);
            }
            else
            {
                if (sourceIndices == null)
                {
                    throw new ArgumentNullException(nameof(sourceIndices));
                }
                if (destinationIndex < 0)
                {
                    throw new ArgumentOutOfRangeException(nameof(destinationIndex));
                }
                if (destinationIndex + sourceIndices.Count > destination.Length)
                {
                    throw new ArgumentException("The given buffer must have an equal or greater length than destinationIndex+length");
                }

                destination.Fill(column.DefaultValue, destinationIndex, sourceIndices.Count);
            }
        }
Beispiel #22
0
 void ILogSourcesManagerInternal.OnTimegapsChanged(ILogSource logSource)
 {
     if (OnLogTimeGapsChanged != null)
     {
         OnLogTimeGapsChanged(logSource, EventArgs.Empty);
     }
 }
Beispiel #23
0
 public List<LogEntry> ReadFromEnd(ILogSource source)
 {
     // TODO: use injecting dependecies to build proper log reader (file, sql, ...)
     // for now let's just read from file
     var fileSource = (FileLogSource) source;
     return new FileLogReader(fileSource).ReadFromEnd(500);
 }
 /// <summary>
 ///     Retrieves a list of cells for a given column from this log file.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="logSource"></param>
 /// <param name="sourceIndices"></param>
 /// <param name="column"></param>
 /// <param name="destination"></param>
 public static void GetColumn <T>(this ILogSource logSource,
                                  IReadOnlyList <LogLineIndex> sourceIndices,
                                  IColumnDescriptor <T> column,
                                  T[] destination)
 {
     logSource.GetColumn(sourceIndices, column, destination, 0, LogSourceQueryOptions.Default);
 }
Beispiel #25
0
 void ILogSourcesManagerInternal.FireOnLogSourceRemoved(ILogSource sender)
 {
     if (OnLogSourceRemoved != null)
     {
         OnLogSourceRemoved(sender, EventArgs.Empty);
     }
 }
Beispiel #26
0
 void ILogSourcesManagerInternal.OnSourceVisibilityChanged(ILogSource t)
 {
     if (OnLogSourceVisiblityChanged != null)
     {
         OnLogSourceVisiblityChanged(this, EventArgs.Empty);
     }
 }
Beispiel #27
0
        protected override void UpdateWidth(ILogSource logSource, TextSettings textSettings)
        {
            int lineNumberCharacterCount;

            if (logSource != null)
            {
                var lineCount = logSource.GetProperty(TextProperties.LineCount);
                if (lineCount > 0)
                {
                    lineNumberCharacterCount = (int)Math.Ceiling(Math.Log10(lineCount));
                }
                else
                {
                    lineNumberCharacterCount = 0;
                }
            }
            else
            {
                lineNumberCharacterCount = 0;
            }

            // We always reserve space for at least 3 characters.
            _lineNumberWidth = textSettings.EstimateWidthUpperLimit(Math.Max(lineNumberCharacterCount, val2: 3));
            Width            = _lineNumberWidth + textSettings.LineNumberSpacing;
        }
Beispiel #28
0
        private void OnLogFileChanged(ILogSource oldValue, ILogSource newValue)
        {
            oldValue?.RemoveListener(this);

            PartTextCanvas.LogSource = newValue;

            if (newValue != null)
            {
                newValue.AddListener(this, TimeSpan.FromMilliseconds(value: 100), maximumLineCount: 10000);

                _maxLineWidth = (int)Math.Ceiling(_textSettings.EstimateWidthUpperLimit(newValue.GetProperty(TextProperties.MaxCharactersInLine)));
                UpdateScrollViewerRegions();
                PartTextCanvas.DetermineVerticalOffset();
                PartTextCanvas.UpdateVisibleSection();
                PartTextCanvas.UpdateVisibleLines();
            }
            else
            {
                _maxLineWidth = 0;
                TextCanvasOnVisibleLinesChanged();
                UpdateScrollViewerRegions();
            }

            MatchScrollbarValueToCurrentLine();
        }
        public void TestOpenBeforeCreate()
        {
            ILogSource logSource = null;

            try
            {
                string fileName = PathEx.GetTempFileName();
                if (File.Exists(fileName))
                {
                    File.Delete(fileName);
                }

                new Action(() => logSource = Create(fileName)).Should().NotThrow();

                logSource.Property(x => x.GetProperty(Properties.PercentageProcessed)).ShouldAfter(TimeSpan.FromSeconds(5)).Be(Percentage.HundredPercent);
                logSource.Property(x => x.GetProperty(Properties.EmptyReason)).ShouldAfter(TimeSpan.FromSeconds(5)).NotBeNull("Because the specified file doesn't exist");

                File.WriteAllText(fileName, "Hello World!");

                logSource.Property(x => x.GetProperty(Properties.EmptyReason)).ShouldAfter(TimeSpan.FromSeconds(5)).Be(null,
                                                                                                                       "Because the file has been created now");
                logSource.Property(x => x.GetProperty(Properties.LogEntryCount)).ShouldAfter(TimeSpan.FromSeconds(5)).Be(1, "Because one line was written to the file");

                var entry = logSource.GetEntry(0);
                entry.Index.Should().Be(0);
                entry.RawContent.Should().Be("Hello World!");
            }
            finally
            {
                logSource?.Dispose();
            }
        }
        public ILogSource CreateParser(IServiceContainer services, ILogSource source)
        {
            var format = source.GetProperty(Properties.Format);
            var logSourceParserPlugins = _pluginLoader?.LoadAllOfTypeWithDescription <ILogSourceParserPlugin>() ?? Enumerable.Empty <IPluginWithDescription <ILogSourceParserPlugin> >();

            foreach (var plugin in logSourceParserPlugins)
            {
                var parser = TryCreateParser(plugin, source);
                if (parser != null)
                {
                    return(parser);
                }
            }

            var logEntryParserPlugins = _pluginLoader?.LoadAllOfTypeWithDescription <ILogEntryParserPlugin>() ?? Enumerable.Empty <IPluginWithDescription <ILogEntryParserPlugin> >();

            foreach (var plugin in logEntryParserPlugins)
            {
                var parser = TryCreateParser(plugin, format);
                if (parser != null)
                {
                    return(new GenericTextLogSource(source, parser));
                }
            }

            return(new GenericTextLogSource(source, new GenericTextLogEntryParser()));
        }
        public PresentationLogSource(ITaskScheduler scheduler, ILogSource source, TimeSpan maximumWaitTime, TextSettings textSettings)
            : base(scheduler)
        {
            if (scheduler == null)
            {
                throw new ArgumentNullException(nameof(scheduler));
            }
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }

            _maximumWaitTime = maximumWaitTime;
            _textSettings    = textSettings;
            _source          = source;

            _indices = new LogBufferList(IndexedColumns);

            _array = new LogBufferArray(MaximumLineCount, Core.Columns.RawContent);
            _pendingModifications = new ConcurrentQueue <PendingModification>();
            _syncRoot             = new object();

            _source.AddListener(this, _maximumWaitTime, MaximumLineCount);
            StartTask();
        }
Beispiel #32
0
 void ILogSourcesManagerInternal.OnSourceTrackingChanged(ILogSource t)
 {
     if (OnLogSourceTrackingFlagChanged != null)
     {
         OnLogSourceTrackingFlagChanged(t, EventArgs.Empty);
     }
 }
Beispiel #33
0
        public static async Task <IBookmark> CreateTogglableBookmark(
            this ILogSource ls,
            IBookmarksFactory factory,
            IBookmark sourceBookmark,
            CancellationToken cancallation
            )
        {
            if (sourceBookmark.LogSourceConnectionId != ls.Provider.ConnectionId)
            {
                throw new ArgumentException("log source and bookmark have inconsistent connection ids");
            }
            IMessage messageAtPosition = null;
            await ls.Provider.EnumMessages(
                sourceBookmark.Position,
                msg =>
            {
                if (msg.Position == sourceBookmark.Position)
                {
                    messageAtPosition = msg;
                }
                return(false);
            },
                EnumMessagesFlag.Forward,
                LogProviderCommandPriority.RealtimeUserAction,
                cancallation
                );

            if (messageAtPosition == null)
            {
                return(null);
            }
            return(factory.CreateBookmark(messageAtPosition, sourceBookmark.LineIndex, true));
        }
Beispiel #34
0
 public Message(INetwork network, ILogSource source, IUser user, string message, bool highlight)
     : base(network, source, user)
 {
     this.User = user;
     this.NicknameContinuity = user.Nickname;
     this.MessageBody = message;
     this.Highlight = highlight;
 }
        public override ParsingResult ParseLogs(ILogSource source, LogReaderSettings settings)
        {
            if (AzureSourceStateStorage.ParsingResultWithoutFiltering == null)
                AzureSourceStateStorage.ParsingResultWithoutFiltering = base.ParseLogs(source, null);

            ParsingResult result = FilterLogs(AzureSourceStateStorage.ParsingResultWithoutFiltering, settings);
            return ReorginizeParsingResult(result);
        }
Beispiel #36
0
	public static void Err(ILogSource loggr, RestServiceException ex)
	{
		string msg = ""; switch (ex.Code)
		{
			case HttpStatusCode.InternalServerError:
				msg = "TODO: make this specific";
				break;
		}

		OnAnyEvent.Error(loggr, ex, msg);
	}
        public LogCollectionViewModel()
        {
            this.Status = CollectionStatus.NotConnected;
            this.Loggers = new ReactiveList<LogCollectionFilterViewModel<string>>() { ChangeTrackingEnabled = true };
            this.LogLevels = new ReactiveList<LogCollectionFilterViewModel<LogLevel>>() { ChangeTrackingEnabled = true };
            this.LogMachines = new ReactiveList<LogCollectionFilterViewModel<string>>() { ChangeTrackingEnabled = true };
            this.LogApplications = new ReactiveList<LogCollectionFilterViewModel<string>>() { ChangeTrackingEnabled = true };

            this.LogLevels.Add(new LogCollectionFilterViewModel<LogLevel>(LogLevel.Info, "Info"));
            this.LogLevels.Add(new LogCollectionFilterViewModel<LogLevel>(LogLevel.Warn, "Warn", true));
            this.LogLevels.Add(new LogCollectionFilterViewModel<LogLevel>(LogLevel.Error, "Error", true));
            this.LogLevels.Add(new LogCollectionFilterViewModel<LogLevel>(LogLevel.Fatal, "Fatal", true));

            this.logsSource = new RabbitMqLogCollection();
            this.logsSource
                .ObserveOnDispatcher()
                .Subscribe(this.AddToLogs);

            this.logs = new ReactiveList<LogEntry>() { ChangeTrackingEnabled = true };
            this.logs.CountChanged
                .Where(i => i > MaxItemInList)
                .Subscribe(i => this.logs.RemoveRange(MaxItemInList - 1, i - MaxItemInList));

            this.Logs = this.logs.CreateDerivedCollection(l => l, this.FilterLogList);

            this.Charts = new ChartsViewModel();
            this.Charts.SetSource(this.logsSource);

            Func<ChartPointViewModel, LogEntry, ChartPointViewModel> aggregator = (acc, logEntry) =>
			{
                acc.Count++;
				return acc;
			};

            this.LevelsChart = this.Charts.AddChart(l => l.Level.ToString(), aggregator, l => l.Level > LogLevel.Info);
            this.ApplicationsChart = this.Charts.AddChart(l => l.Application, aggregator, l => l.Level > LogLevel.Info);

            this.Parameters = new RabbitMQConfigurationViewModel();
            this.ConnectToLogCollection();

            this.Parameters.Changed
                .Buffer(() => this.ObservableForProperty(t => t.Parameters.IsEditing).Where(p => !p.Value))
                .Where(ps => ps.Any(p => p.PropertyName != nameof(this.Parameters.IsEditing)))
                .Subscribe(_ => this.ConnectToLogCollection());

            Observable.Merge(
                this.Loggers.ItemChanged.Select(_ => Unit.Default),
                this.LogLevels.ItemChanged.Select(_ => Unit.Default),
                this.LogApplications.ItemChanged.Select(_ => Unit.Default),
                this.LogMachines.ItemChanged.Select(_ => Unit.Default))
                .ObserveOnDispatcher()
                .Subscribe(_ => this.Logs.Reset());
        }
Beispiel #38
0
	public static void Err(ILogSource loggr, RestServiceException ex)
	{
		bool showInnerException = true;
		string msg = ""; switch (ex.Code)
		{
			case HttpStatusCode.NotFound:
				msg = "Requested node does not exist on the server.";
				showInnerException = false;
				break;
		}

		OnAnyEvent.Error(loggr, ex, msg, showInnerException);
	}
Beispiel #39
0
	public static bool Err(ILogSource loggr, RestServiceException ex)
	{
		bool showInnerException = true;
		string msg = ""; switch (ex.Code)
		{
			case HttpStatusCode.BadRequest:
				msg = "Invalid field values.";
				showInnerException = false;
				break;
		}

		OnAnyEvent.Error(loggr, ex, msg, showInnerException);
		return false;
	}
Beispiel #40
0
	public static bool Err(ILogSource loggr, RestServiceException ex)
	{
		bool showInnerException = true;
		string msg = ""; switch (ex.Code)
		{
			case HttpStatusCode.NotFound:
				msg = "Resource not found:  " + ex.BaseUrl.Slash(ex.Resource);
				showInnerException = false;
				break;			
		}

		OnAnyEvent.Error(loggr, ex, msg, showInnerException);
		return false;
	}
Beispiel #41
0
		/// <summary>
		/// Initializes a new instance of the <see cref="LogMessage"/>.
		/// </summary>
		/// <param name="source">The log source.</param>
		/// <param name="time">Message creating time.</param>
		/// <param name="level">The level of the log message.</param>
		/// <param name="getMessage">The function returns the text for <see cref="LogMessage.Message"/>.</param>
		public LogMessage(ILogSource source, DateTimeOffset time, LogLevels level, Func<string> getMessage)
		{
			if (source == null)
				throw new ArgumentNullException(nameof(source));

			if (getMessage == null)
				throw new ArgumentNullException(nameof(getMessage));

			_getMessage = getMessage;

			Source = source;
			Time = time;
			Level = level;
		}
Beispiel #42
0
        public static bool Err(ILogSource loggr, RestServiceException ex)
        {
            bool showInnerException = true;
            string msg = ""; switch (ex.Code)
            {
                case HttpStatusCode.Unused:
                    var usr = ex.InnerException.Message.Between("Access denied for user ", ").", true);
                    msg = "{0} is not allowed to delete this node.".f(usr.Quotify());
                    showInnerException = false;
                    break;
            }

            OnAnyEvent.Error(loggr, ex, msg, showInnerException);
            return false;
        }
Beispiel #43
0
        public LogScrollerVM ListenTo(ILogSource logSource, string logFileName = null)
        {
            DisplayName = logSource.GetType().Name;

            _source = logSource;
            //_source.LogAdded += AppendRichText;

            _source.LogAdded += (s, e) => 
            {
                ApppendLogsTo(logFileName, e);
                RichText = _rtf.RewriteToInclude(e);

            };
            return this;
        }
		public LogViewController (IConcurrencyService concurrencyService, ILogSource logSource)
		{
			_logSource = logSource;
			_concurrencyService = concurrencyService;

			Title = "Logs";
			TabBarItem.Image = UIImage.FromBundle ("adaptive");

			_logSource.LogSource
				.ObserveOn(_concurrencyService.Dispatcher)
				.Subscribe ((string message) => {
					if (!_isInitialised)
						_messages.Add (message);
					else
						OnMessage(message);
			});
		}
Beispiel #45
0
	public static void Err(ILogSource loggr, RestServiceException ex)
	{
		string msg = ""; switch (ex.Code)
		{
			case HttpStatusCode.Forbidden:
				msg = "SSL certificate is invalid.";
				break;
				
			case HttpStatusCode.ServiceUnavailable:
				msg = "Unable to reach the server."; 
				break;
			
			case HttpStatusCode.Unauthorized:
				msg = "Server rejected application credentials.";
				break;
		}
		
		OnAnyEvent.Error(loggr, ex, msg);
	}
Beispiel #46
0
        public static bool AddCertificate(string fileName, ILogSource logr)
        {
            logr.Trace_i($"Installing {fileName}...");
            var file = Self.Folder.File(fileName);
            if (!file.Found) return logr.Error_o("File not found");

            try
            {
                var cert = new X509Certificate2(file.Path);
                var stor = new X509Store(StoreName.TrustedPeople, StoreLocation.CurrentUser);
                stor.Open(OpenFlags.ReadWrite);
                stor.Add(cert);
                stor.Close();
                return logr.Trace_o("Successfully installed bundled certificate.");
            }
            catch (Exception ex)
            {
                return logr.Error_o("Error encountered." + L.F + ex.Details(false, false));
            }
        }
Beispiel #47
0
	public static bool Err(ILogSource loggr, RestServiceException ex)
	{
		bool showInnerException = true;
		string msg = ""; switch (ex.Code)
		{
			case HttpStatusCode.NotAcceptable:
				msg = "Invalid JSON object format.";
				showInnerException = false;
				break;
			
			case HttpStatusCode.Forbidden:
				var usr = ex.InnerException.Message.Between("Access denied for user ", ").", true);
				msg = "{0} is not allowed to edit this node.".f(usr.Quotify());
				showInnerException = false;
				break;
		}

		OnAnyEvent.Error(loggr, ex, msg, showInnerException);
		return false;
	}
 protected override ParsingResult ParseSource(ILogSource source, LogReaderSettings settings, ParsingResult result = null)
 {
     if (source == null)
         throw new ArgumentNullException(nameof(source));
     
     TextStorage storage = new TextStorage();
     result = result ?? new ParsingResult();
     var log = (IEnumerable<string[]>)source;
     if (!(source is AzureLogSource))
         throw new ApplicationException("Non Azure log source was tried to be parsed by Azure log reader");
     
     foreach (var lines in log)
     {
         var logEntry = logParser.ParseLine(lines[0], new DateTime(long.Parse(lines[1])), storage);
         if (logEntry != null)
         {
             logEntry = AnalyzeLog(logEntry, storage);
             result.AddToGroupAll(logEntry);
         }
     }
     return result;
 }
Beispiel #49
0
 public UserEvent(INetwork network, ILogSource source, IUser user)
     : base(network, source)
 {
     this.User = user;
     this.NicknameContinuity = this.User.Nickname;
 }
Beispiel #50
0
 public Part(INetwork network, ILogSource source, IUser user)
     : base(network, source, user)
 {
 }
Beispiel #51
0
		/// <summary>
		/// Initializes a new instance of the <see cref="LogMessage"/>.
		/// </summary>
		/// <param name="source">The log source.</param>
		/// <param name="time">Message creating time.</param>
		/// <param name="level">The level of the log message.</param>
		/// <param name="message">Text message.</param>
		/// <param name="args">Text message settings. Used if a message is the format string. For details, see <see cref="string.Format(string,object[])"/>.</param>
		public LogMessage(ILogSource source, DateTimeOffset time, LogLevels level, string message, params object[] args)
			: this(source, time, level, () => message.Put(args))
		{
		}
 public FilteredRecordCollection(ILogSource logSource, Predicate<Record> filter) : base(logSource) {
     this.filter = filter;
 }
 public LogAnalyzer(ILogSource logSource, ILogger logger)
 {
     _logSource = logSource;
     _logger = logger;
 }
Beispiel #54
0
 public Nick(INetwork network, ILogSource source, IUser user, string oldNickname)
     : base(network, source, user)
 {
     base.NicknameContinuity = oldNickname;
 }
Beispiel #55
0
 public Quit(INetwork network, ILogSource source, IUser user, string message)
     : base(network, source, user)
 {
     this.Message = message;
 }
 public void AddSource(ILogSource logSource)
 {
 }
Beispiel #57
0
		private string GetSourceName(ILogSource source)
		{
			if (source == null)
				throw new ArgumentNullException(nameof(source));

			var name = source.Name;

			if (!source.IsRoot && WriteChildDataToRootFile && source.Parent != null)
				name = GetSourceName(source.Parent);

			return name;
		}
 public void AddSource(ILogSource logSource)
 {
     _logSources.Add(logSource);
 }
Beispiel #59
0
 public LogEntry(INetwork network, ILogSource source)
 {
     this.Network = network;
     this.Source = source;
     this.ReceivedAt = DateTime.Now;
 }
Beispiel #60
0
 public void Log(ILogSource source)
 { 
     // Log the message 
 
 }