GithubHelp home page GithubHelp logo

yarseyah / sentinel Goto Github PK

View Code? Open in Web Editor NEW
224.0 18.0 64.0 3.85 MB

Sentinel is a log-viewer with configurable filtering and highlighting (foreground/background colours)

License: Microsoft Public License

C# 100.00%

sentinel's Introduction

sentinel

Log-viewer with filtering and highlighting

Log Sources

Sentinel is a viewer for log-files - specifically I designed it to act as a network end-point for the likes of nLog and log4net, additionally it then works really well for capturing log entries from multiple sources.

Source Status
Log4Net UdpAppender Supported
nLog's nLogViewer Supported
Trace Listener Planned
Log-File Watcher Experimental
Custom, via plug-in Planned
MSBuild Plug-in in source-repo

Command-Line usage

There are command line options that allow control over Sentinel when started, options available include the following:

  • Loading of a saved Session File
  • nLog network listener
  • log4net network listener

Command line options

If no command line options are specified, the standard New Session wizard will launch at start-up.

Launch with NLog listener enabled

sentinel nlog [--port <port-number>] [--tcp]

Defaults to port 9999 and Udp if not specified.

Launch with Log4Net listener enabled

sentinel log4net [--port <port-number>]

Defaults to port 9998 if not specified.

Launch with previously saved session file

sentinel filename.SNTL

nLog's NLogViewer target configuration

To allow a nLog based application transmit its log messages to Sentinel, use a configuration like the one shown below:

<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <targets>
    <target xsi:type="NLogViewer"
            name="viewer"
            address="udp://127.0.0.1:9999"/>
  </targets>
  <rules>
    <logger name="*"
            minlevel="Debug"
            writeTo="viewer" />
  </rules>
</nlog>

Showing nLog debug information (0.12.0.0 onwards)

If the above configuration is adjusted to enable {{includeSourceInfo}} then it is possible to see the file, class, method and line number corresponding to where the message is emitted. Some of this information is only reported if the source program is compiled in DEBUG mode (e.g. RELEASE mode strips this information)

<target name="viewer"
        xsi:type="NLogViewer"
        includeSourceInfo="true"
        address="udp://127.0.0.1:9999" />

Log4Net UdpAppender configuration

To allow a log4net application transmit its log messages to Sentinel, use a configuration like the one shown below:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <section name="log4net"
             type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
  </configSections>

  <log4net>
    <appender name="udp"
              type="log4net.Appender.UdpAppender">

      <RemoteAddress value="127.0.0.2"/>
      <RemotePort value="9999"/>
      <layout type="log4net.Layout.XmlLayout"/>
      <encoding value="utf-8" />
    </appender>

    <root>
      <appender-ref ref="udp"/>
    </root>
  </log4net>
</configuration>

Showing log4net debug information (0.12.1.0 onwards)

If the above configuration is adjusted to enable {{locationInfo}} then it is possible to see the file, class, method and line number corresponding to where the message is emitted. Some of this information is only reported if the source program is compiled in DEBUG mode (e.g. RELEASE mode strips this information)

<layout type="log4net.Layout.XmlLayout">
    <locationInfo value="true" />
</layout>

Log Entries

Log file entries map the the following interface. This is core record for a log-file entry and used to populate the columns within the live-log view. Note, by using Classifiers it is possible to rearrange and/or change the content of these fields upon receiving a new log-entry.

public interface ILogEntry
{
    string Classification { get; set; }
    DateTime DateTime { get; set; }
    string Description { get; set; }
    string Source { get; set; }
    string System { get; set; }
    string Thread { get; set; }
    string Type { get; set; }
}

Log entries may be classified, highlighted and filtered based upon special services:

  • Classifiers can change the properties of a log entry
  • Highlighters can change its appearance.
  • Filters can be used to suppress the displaying of matching entries.

Classifiers

Upon receiving a new log-entry it is processed through registered classifiers. Classifiers have the ability to rewrite the log-entry prior to passing it to the visualisation aspect of Sentinel.

As an example, suppose the incoming message when starting with the phrase "Sleeping for another" is intended to be switched from its supplied type (e.g. DEBUG or INFO) to its own type Timing. The ClassifierViewModel registers this on construction. Note that the regular expression below also rewrites the Description to the named-capture description, effectively stripping off the prefix "Sleeping for another" - information no longer needed due to the reclassification.

items.Add(
	new DescriptionTypeClassifier("Timing", "Timing")
		{
			Enabled = true,
			Name = "Timing messages",
			RegexString = @"^Sleeping for another (?<description>[^$](^$)+)$"
		});

In addition to reclassifying messages, the Classifier mechanism is currently used to make other changes to the message appearance. Continuing the example above, using a {{TypeImageClassifier}} it is possible to specify the image to be used for entries with a type of Timing.

items.Add(
	new TypeImageClassifier("Timing", "/Resources/Clock.png")
		{
			Enabled = true,
			Name = "Timing Image",
		});

The classifiers can be seen in the Preferences dialog-box.

Preferences - Classifiers

Highlighters

Customisable and extendible highlighters that may be toggled on and off during live preview. The current implementation limits pattern matching to the Type and System fields, although this will be extended to all fields. An example of why this is useful, in the classifiers section above, a new type of "Timing" was added, this type can get its own highlighting style.

Preferences - Highlighters

Highlighters can match the contents of the Type and System fields

  • Exact Strings
  • Substrings
  • Regular Expressions

Adding Regex Highlighter

If the matching field is set to Type an the match string specified as "Timing", a new highlighter for the timing can be added. User-defined highlighters are automatically added to the toolbar for ease of enabling and disabling of the highlighting.

Toolbar - User defined highlighters

The highlighters work on a first-come, wins principle. Therefore, the order of the entries in the highlighters section of the Preferences dialog-box are important. It is possible to hide the highlighting of FATAL messages if a highlighter is positioned before FATAL and gets a match.

Filters

Filters are very much like highlighters except their purpose is to remove log-entries from the displayed values (note, the values are not lost, just hidden). Filters may be toggled on and off during the session. Filters are evaluated in the order specified, but since filters works on an any-match = hide principle the evaluation stops on the first match, resulting on the entry being hidden. Note, this means that messages displayed have travelled through ALL of the filters without being matched, this isn't a cost free aspect, so be careful about how many enabled filters you have!

Extractors

Extractors are the inverse of Filters, log entries must match the extractor to be visible. This can be very useful if you, for example, define an extractor for a specific logging condition and want to quickly see if and how often it happened.

sentinel's People

Contributors

240026763 avatar 70b43r avatar a9g-data-droid avatar azure-pipelines[bot] avatar crustyapplesniffer avatar dependabot[bot] avatar snakefoot avatar yarseyah avatar zhangyueqiu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sentinel's Issues

Crush on run

Hi. When I run latest version, it's crushes with this exception (Win7 x64):

Application: Sentinel.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.NullReferenceException
at MS.Internal.FontCache.FontFaceLayoutInfo+IntMap.TryGetValue(Int32, UInt16 ByRef)
at System.Windows.Media.GlyphTypeface.Initialize(System.Uri, System.Windows.Media.StyleSimulations)
at MS.Internal.Xaml.Runtime.ClrObjectRuntime.InitializationGuard(System.Xaml.XamlType, System.Object, Boolean)
at System.Xaml.XamlObjectWriter.Logic_EndInit(MS.Internal.Xaml.Context.ObjectWriterContext)
at System.Xaml.XamlObjectWriter.WriteEndObject()
at System.Windows.Markup.WpfXamlLoader.TransformNodes(System.Xaml.XamlReader, System.Xaml.XamlObjectWriter, Boolean, Boolean, Boolean, System.Xaml.IXamlLineInfo, System.Xaml.IXamlLineInfoConsumer, MS.Internal.Xaml.Context.XamlContextStack`1<System.Windows.Markup.WpfXamlFrame>, System.Windows.Markup.IStyleConnector)
at System.Windows.Markup.WpfXamlLoader.Load(System.Xaml.XamlReader, System.Xaml.IXamlObjectWriterFactory, Boolean, System.Object, System.Xaml.XamlObjectWriterSettings, System.Uri)
at System.Windows.Markup.WpfXamlLoader.LoadBaml(System.Xaml.XamlReader, Boolean, System.Object, System.Xaml.Permissions.XamlAccessLevel, System.Uri)
at System.Windows.Markup.XamlReader.LoadBaml(System.IO.Stream, System.Windows.Markup.ParserContext, System.Object, Boolean)
at Sentinel.Controls.MainWindow..ctor()

Exception Info: System.Reflection.TargetInvocationException
at System.RuntimeTypeHandle.CreateInstance(System.RuntimeType, Boolean, Boolean, Boolean ByRef, System.RuntimeMethodHandleInternal ByRef, Boolean ByRef)
at System.RuntimeType.CreateInstanceSlow(Boolean, Boolean, Boolean, System.Threading.StackCrawlMark ByRef)
at System.Activator.CreateInstance(System.Type, Boolean)
at System.RuntimeType.CreateInstanceImpl(System.Reflection.BindingFlags, System.Reflection.Binder, System.Object[], System.Globalization.CultureInfo, System.Object[], System.Threading.StackCrawlMark ByRef)
at System.Activator.CreateInstance(System.Type, System.Reflection.BindingFlags, System.Reflection.Binder, System.Object[], System.Globalization.CultureInfo, System.Object[])
at System.Activator.CreateInstance(System.Type, System.Object[])
at System.Xaml.Schema.SafeReflectionInvoker.CreateInstanceCritical(System.Type, System.Object[])
at System.Xaml.Schema.XamlTypeInvoker.CreateInstance(System.Object[])
at MS.Internal.Xaml.Runtime.ClrObjectRuntime.CreateInstance(System.Xaml.XamlType, System.Object[])
at System.Xaml.XamlObjectWriter.Logic_CreateAndAssignToParentStart(MS.Internal.Xaml.Context.ObjectWriterContext)
at System.Xaml.XamlObjectWriter.WriteStartMember(System.Xaml.XamlMember)
at System.Windows.Markup.WpfXamlLoader.TransformNodes(System.Xaml.XamlReader, System.Xaml.XamlObjectWriter, Boolean, Boolean, Boolean, System.Xaml.IXamlLineInfo, System.Xaml.IXamlLineInfoConsumer, MS.Internal.Xaml.Context.XamlContextStack`1<System.Windows.Markup.WpfXamlFrame>, System.Windows.Markup.IStyleConnector)
at System.Windows.Markup.WpfXamlLoader.Load(System.Xaml.XamlReader, System.Xaml.IXamlObjectWriterFactory, Boolean, System.Object, System.Xaml.XamlObjectWriterSettings, System.Uri)
at System.Windows.Markup.WpfXamlLoader.LoadBaml(System.Xaml.XamlReader, Boolean, System.Object, System.Xaml.Permissions.XamlAccessLevel, System.Uri)
at System.Windows.Markup.XamlReader.LoadBaml(System.IO.Stream, System.Windows.Markup.ParserContext, System.Object, Boolean)
at System.Windows.Application.LoadBamlStreamWithSyncInfo(System.IO.Stream, System.Windows.Markup.ParserContext)
at System.Windows.Application.DoStartup()
at System.Windows.Application.<.ctor>b__1_0(System.Object)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
at System.Windows.Threading.DispatcherOperation.InvokeImpl()
at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
at MS.Internal.CulturePreservingExecutionContext.Run(MS.Internal.CulturePreservingExecutionContext, System.Threading.ContextCallback, System.Object)
at System.Windows.Threading.DispatcherOperation.Invoke()
at System.Windows.Threading.Dispatcher.ProcessQueue()
at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
at MS.Win32.HwndWrapper.WndProc(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(System.Windows.Threading.DispatcherPriority, System.TimeSpan, System.Delegate, System.Object, Int32)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(System.Windows.Interop.MSG ByRef)
at System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame)
at System.Windows.Application.RunDispatcher(System.Object)
at System.Windows.Application.RunInternal(System.Windows.Window)
at Sentinel.MainApplication.Main()

Squirrel upgrader error

Using the latest release, a big red banner at the top: "Squirrel upgrader has the following errrors
Updater.exe is not found, not a Squirrel-installed app?"

I'm using NLog provider from a WinForms desktop app, .net framework

Support for Serilog

Hello Ray, Is there any planning to support serilog logging provider ? Thanks in advance.

Portable version

Are there any plans on a portable version of sentinel which does not require an installation?

Pull Request #24 incorrectly updated testers

Test applications, e.g. the v2 and v3 of the nLogTester were all upgraded to v4 of nlog, these need reverting.

Additionally, v1 uses a third-party reference directly to a binary, it should use nuget.

Load existing file?

Hello,

i create a new logger and select a file. I only want to view an existing file.
Provider is the "File Monitoring Provider".
Then I select the file and check the box "Load existing content from file".
Decoder Format "nLog default...:".
Then the application starts, but there are no entries from file.
Everything is empty.
What am I doing wrong?

Best Regards, Alex

FileMonitor SNTL file not loading Properly

I have an nlog generated log file that I would like to view in Sentinel. When I load sentinel and go through the wizard, the provider works as expected. However, when I save the sntl file and reload sentinel with it, the information is blank and doesn't update with new entries.

Support for json log files

Any chance you could add support for json logs
Example:

{ "time": "2018-04-05 14:41:24.4791", "level": "INFO", "thread": "15 ", "message": "Request received (\"DB\", \"Save\")", "module": "DB", "method": "Save" }
{ "time": "2018-04-05 14:41:24.4986", "level": "INFO", "thread": "4 ", "message": "Request received (\"DB\", \"GetAll\")", "module": "DB", "method": "GetAll" }
{ "time": "2018-04-05 14:41:24.4986", "level": "INFO", "thread": "13 ", "message": "it took 12,2139 ms to write to disk", "elapsedMilliseconds": 12.2139 }

(Generated by NLog structured logging)

WPF UserControl

We've used Sentinel internally for years, but I'm considering pulling some of the code out of the project and adding it in a separate tab inside of our applications for debug purposes. I'll comply with the license (of course) and keep my stripped down version in a fork on GitHub.

Ideally, this could be wrapped up into a NuGet package for distribution and maybe pulled back into the master, though I'm not sure I'll get that far.

I just didn't want to do the work without letting the author and others know.

Clear window

Amazing app, been struggling with others and found sentinel! Pleased isn't in it!

Question: I would like to clear the log viewer main window by sending a magic string eg nlogr.Trace("clear the sentinel screen please")

Or do you have any other way of accomplishing this lazy mans functionality??

Cheers

Limit number of log entries displayed

I think it would be handy to implement feature to limit the log entries, displayed in the GUI, by a configurable maximum count and/or log age.

This way it is safe to just let sentinel run without memory consumption only ever increasing.
Currently I am having an issue where the log window is not really (at all) responsive any more and Sentinel is eating 6 GB of memory due to the shear amount of shown logs.

Program freezing quite often

Hi,

we are developing a WPF program which is sending NLOG messages all few milliseconds.
Usually we had no problems with Sentinel but version 0.14.1.0 is freezing quite often (independent from Windows version), especially by using Clear and Pause functions.
Force close via Task Manager required.
After restart of Sentinel it will not take long to freeze again.

Do you have any suggestions or can I provide more information?

Best regards,
Patrick

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.