WebLogger 1.0.1
See the version list below for details.
dotnet add package WebLogger --version 1.0.1
NuGet\Install-Package WebLogger -Version 1.0.1
<PackageReference Include="WebLogger" Version="1.0.1" />
paket add WebLogger --version 1.0.1
#r "nuget: WebLogger, 1.0.1"
// Install WebLogger as a Cake Addin #addin nuget:?package=WebLogger&version=1.0.1 // Install WebLogger as a Cake Tool #tool nuget:?package=WebLogger&version=1.0.1
Weblogger
Websocket server designed to provide an accessible console application to a Crestron VC4 program instance Note: a migration to netstandard now allows this project to be used on any platform. see the console application demo program the crestron SDK is only refernced by the Crestron implementations.
Table of Contents
Visual Studio Solution
The included solution includes four projects including two examples and 2 libraries.
- /source/
WebLogger
- /source/
WebLogger.Crestron
- /example/
WebLogger.ConsoleApp
- /example/
WebLogger.CrestronApp
WebLogger Library
This is lowest level library including all WebLogger types and logic. This library has two dependancies; Serilog, and WebSocketSharp
WebLogger.Crestron Library
Adds a reference to the Crestron SDK. This library simply adds an unsecured http server to distrubute the HTML files. Since browsers will block ws when the html page is served via https this server solves issues using unsecured webservers.
WebLogger.ConsoleApp Example Program
The Weblogger example is a simple console application showing SerilogSink usage.
WebLogger.CrestronApp Example Program
The Weblogger example is a Crestron SDK SimpleSharp program that demonstrates how to instantiate the WebLogger
class and add console commands with callbacks.
Create a WebLogger
Create a new instance of the WebLoger
class included in the using WebLogger
namespace. Creating a new instace will:
- Create a Websocket Server at the specified port
- Copy all embedded resource HTML files to your local file system at the specified directory
- Create a few default console commands
using Serilog;
using WebLogger;
Create a new instance and start the server
// Option 1: Let the sink extension Create the instance.
// When logger is closed and flushed the web logger will be disposed and stopped.
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Verbose()
.WriteTo.WebloggerSink(54321, false, "C:/Temp/")
.WriteTo.Console()
.CreateLogger();
Option 2: Create the logger and pass it into the sink.
// Option 2: Create a logger and pass it into the Sink Extension
// When logger is closed and flushed the web logger will be disposed and stopped.
var logger = new WebLogger(54321, false, "C:/Temp/");
logger.Start();
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Verbose()
.WriteTo.WebloggerSink(logger)
.WriteTo.Console()
.CreateLogger();
Register Console Commands
Custom console commands be created at any point in the life cycle of the WebLogger
.
To add a custom command create a new instance of the ConsoleCommand
class. Each console command will be added to a dictionary using the Command
property as the key. Each console command should have a pointer to callback method. When a string matching the Command
name is received from the WebLogger
server, the callback will be invoked.
Default Constructor
Using the default constuctor and setting all properties with the object initialization syntax
ConsoleCommands.RegisterCommand(new ConsoleCommand(
"EXAMPLE",
"Simple example of console command",
"Parameter: NA",
(cmd, args) =>
{
Log.Logger.Information("{command} Received", cmd);
}));
ConsoleCommands.RegisterCommand(new ConsoleCommand(
"TEST",
"Simple example of console command",
"Parameter: NA",
(cmd, args) =>
{
Log.Logger.Information("{command} Received", cmd);
}));
Console command callback signature
/// <summary>
/// Console command callback
/// </summary>
/// <param name="command">Command that was issued</param>
/// <param name="arguments">Argument passed into the command seperated by spaces</param>
public void ConsoleCommandCallback(string command, List<string> arguments);
Embedded HTML
Located in the WebLogger
project is a folder titled HTML
. All HTML source files have been added to the project and configured as an embedded resource.
These files will be automatically extracted and written to the provided applicationDirectory
in the weeblogger's default constructor.
public WebloggerSink(IFormatProvider formatProvider, int port, bool secured, string applicationDirectory)
{
_logger = new WebLogger(port, secured, applicationDirectory);
_logger.Start();
_formatProvider = formatProvider;
}
Be aware, the program will check if the files are already created and ONLY write them if they are not found. This means the HTML files will need to be deleted off the server if changees to the HTML are made
After loading the code to your VC4, create a new room and associate it with the program. Once the room has been started browse to /opt/crestron/virtualcontrol/RunningPrograms/[ROOM ID]/html/logger
to review the files on the server.
Files will be served up using the index/html file found at http://server/VirtualControl/Rooms/EXAMPLE/Html/logger/index.html
When using the WebLogger.Crestron library you can create a custom http file server and distibute the HTML page via an unsecured webserver
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Verbose()
.WriteTo.WebloggerSink(54321, false, Directory.GetApplicationRootDirectory())
.CreateLogger();
var webPageServer = new WebLoggerHttpServer(
port: 8081,
directory: Path.Combine(Directory.GetApplicationRootDirectory(), "html/logger/"));
ConsoleCommands.RegisterCommand(new ConsoleCommand(
"EXAMPLE",
"Simple example of console command",
"Parameter: NA",
(cmd, args) =>
{
Log.Logger.Information("{command} Received", cmd);
}));
ConsoleCommands.RegisterCommand(new ConsoleCommand(
"TEST",
"Simple example of console command",
"Parameter: NA",
(cmd, args) =>
{
Log.Logger.Information("{command} Received", cmd);
}));
The above code will result in a url http://ip:8081/index.html While the files will be stored in the application directory /html/logger/
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Serilog (>= 2.12.0)
- WebSocketSharp-netstandard (>= 1.0.1)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on WebLogger:
Package | Downloads |
---|---|
WebLogger.Crestron
Provides a web socket servers used to send/receive console communications from an embedded HTML user interface to a application. This was originally created for use on Crestron VC4 but has since been migrated to netstandard for use in native runtime application. Wraps the weblogger for the use within the crestron SDK |
|
WebLogger.Serilog
A serilog Sink implementation of the weblogger providing a web socket servers used to send/receive console communications from an embedded HTML user interface to a application. |
|
WebLogger.Generators
Source generators used to created custom CLI commands used by the WebLogger console. Simply tag your handler methods with a specific attribute and your command will be generated. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.3.0 | 164 | 7/18/2024 |
1.3.0-alpha.5 | 48 | 7/15/2024 |
1.2.0 | 146 | 7/14/2024 |
1.2.0-alpha.53 | 47 | 7/14/2024 |
1.2.0-alpha.51 | 46 | 7/14/2024 |
1.2.0-alpha.49 | 46 | 7/14/2024 |
1.1.9 | 187 | 3/18/2024 |
1.1.8 | 120 | 3/15/2024 |
1.1.7 | 337 | 6/11/2023 |
1.1.6 | 204 | 6/9/2023 |
1.1.5 | 249 | 6/9/2023 |
1.1.3 | 500 | 6/5/2023 |
1.1.2 | 228 | 6/3/2023 |
1.1.0 | 199 | 6/1/2023 |
1.0.1 | 136 | 5/26/2023 |
1.0.0 | 113 | 5/26/2023 |