GithubHelp home page GithubHelp logo

xiaolu6t / nebulog Goto Github PK

View Code? Open in Web Editor NEW

This project forked from imadytech/nebulog

0.0 0.0 0.0 6.52 MB

A realtime logging project based on Microsoft SignalR, to help developers debugging their projects.

License: Apache License 2.0

C# 13.06% HTML 53.58% CSS 5.62% JavaScript 27.61% PHP 0.14%

nebulog's Introduction

NebuLog - Nebula Logger

A distributed logging tool based on Microsoft SignalR, to help developers debugging their projects.

Update README.md 2020-08-31 Update
There was a new feature added for INebuLog interface: Custom Status monitor.

    /// <summary>
    /// Adding a dynamic status monitor at the right side Custom Stats panel.
    /// </summary>
    /// <param name="statId">The Id of the custom stats(must be an unique value otherwise it will be conflicted afterward.)</param>
    /// <param name="statTitle">The title of the custom stat.</param>
    /// <param name="color">The color you want the stat to display in the panel.</param>
    void AddCustomStats(string statId, string statTitle, string color);

    /// <summary>
    /// Update the stat.
    /// </summary>
    /// <param name="statId">The Id of the custom stat. </param>
    /// <param name="message">The value to display. </param>
    void LogCustomStats(string statId, string message);

Keep in mind these methods only supported in INebuLog so you might need cast the ILogger to INebuLog, for example:

        public HomeController(ILogger<HomeController> logger)
        {
            _logger = logger;
            (_logger as INebuLog).AddCustomStats("customStat", "customStat", "green");
        }

2019-08-08 Update
MyLogger has been renamed to NebuLog. Now you can use Nuget to install the NebuLog instead of refer the source code:

PM> Install-Package imady.NebuLog -Version 0.1.0

2019-01-28 Update
Now the ILogger is extended to IMyLogger if you want to extend some new features more than Microsoft's standard Logxxx(). This is the updated code in Startup.cs:

        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            ...
            Services.Configure<MyLoggerOption>(Configuration.GetSection("MyLoggerOption"));
            services.AddMyLogger();
            Services.AddLogging( builder =>
            {
                builder
                    .AddFilter<MyLoggerProvider>("Microsoft", LogLevel.Trace)
                    .AddConsole()
                    .AddDebug();
            });
            ...
        }
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            ...
if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                //app.UseBrowserLink();
                app.UseDatabaseErrorPage();
            }
            else
            {
                //app.UseExceptionHandler("/Home/Error");
                //this will add the MyLoggerExceptionMiddleWare to intercept any application level exception and logging to MyLogger:
                var myLogger = Services.BuildServiceProvider().GetService<IMyLogger<MyLoggerExceptionMiddleWare>>();
                app.UseMyLoggerException(
                    new MyLoggerExceptionMiddleWareOption(errorHandingPath: "/home/error"),
                    myLogger);
            }

            var option = Services.BuildServiceProvider().GetService< IOptions<MyLoggerOption>>();
            loggerFactory.AddProvider(new MyLoggerProvider(option));
            ...
        }

How to use

  1. Have the MyLoggerServer project deployed to cloud or running on local;
  2. Add MyLogger folder (a VS project) to your solution folder (not yet support Nuget installation);
  3. Refer MyLogger project to the applicaiton that to realtime log;
  4. Add the targeted Url to appsettings.json:
  "MyLoggerOption": {
    "MyLoggerHubUrl": "http://localhost:5000/MyLoggerHub",
    "LogLevel": "Trace"
  }
  1. In Startup.cs, add the MyLogger service to the DI framework:
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            ...
            Services.Configure<MyLoggerOption>(Configuration.GetSection("MyLoggerOption"));
            Services.AddLogging( builder =>
            {
                builder
                    .AddFilter<MyLoggerProvider>("Microsoft", LogLevel.Trace)
                    .AddConsole()
                    .AddDebug();
            });
            ...
        }
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            ...
            var option = Services.BuildServiceProvider().GetService< IOptions<MyLoggerOption>>();
            loggerFactory.AddProvider(new MyLoggerProvider(option));
            ...
        }
  1. Now you can use ILogger<> as usual in your application, e.g. the Controller:
        public IActionResult Index()
        {
            _logger.LogTrace("LogTrace.");
            _logger.LogDebug("LogDebug.");
            _logger.LogInformation("LogInformation.");
            _logger.LogWarning("LogWarning.");
            _logger.LogError("LogError.");
            _logger.LogCritical("LogCritical.");
            return View();
        }

Then the loggins will be streamed to the MyLoggerServer webpage and you may easily debug your applications now.
Alternatively you may use our cloud deployed MyLogger service Free of charge (currently in developing) just simply refer the MyLogger and config our MyLoggerHub url in appsettings.json.

MyLoggerScreenShot

Issues:

  1. The remote side logging was designed for development time debugging purpose instead of production logging, e.g. operation data logging with persistence needs. However we may have the MyLogger upgraded in the future to support more features.
  2. Currently the monitoring web page was realized base on Bootstrap-Datatable, which could be slowed down when bulk amount of logs come to the server side (we suggest click Refresh button above the datatable to clear the data when the web page frame rate decrease to observable level). We will optimize the code in the future to improve the user experience.
  3. Currently only Asp.net core is supported. As Microsoft has released SignalR Client for JavaScript and Java as well, we will add support to these languages in the future. Other languages and platforms are subject to the progress of Microsoft SignalR.

You are welcomed to feedback for comments and advices or fork the MyLogger project.


Credit:
Admin template powered by Charisma
Datatable powered by Bootstrap Table

nebulog's People

Contributors

imadytech avatar

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.