LM-OverlyFastCsharpConsoleLogger 1.1.6

dotnet add package LM-OverlyFastCsharpConsoleLogger --version 1.1.6
                    
NuGet\Install-Package LM-OverlyFastCsharpConsoleLogger -Version 1.1.6
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="LM-OverlyFastCsharpConsoleLogger" Version="1.1.6" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="LM-OverlyFastCsharpConsoleLogger" Version="1.1.6" />
                    
Directory.Packages.props
<PackageReference Include="LM-OverlyFastCsharpConsoleLogger" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add LM-OverlyFastCsharpConsoleLogger --version 1.1.6
                    
#r "nuget: LM-OverlyFastCsharpConsoleLogger, 1.1.6"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package LM-OverlyFastCsharpConsoleLogger@1.1.6
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=LM-OverlyFastCsharpConsoleLogger&version=1.1.6
                    
Install as a Cake Addin
#tool nuget:?package=LM-OverlyFastCsharpConsoleLogger&version=1.1.6
                    
Install as a Cake Tool

OOCCL

A simple lightweight console logger I tried to make fast. The NuGet package and example of how it looks in console; image

Key features include:

  1. Multithreadingly(yet not too many threads) printing list of logs
  2. not too complex
  3. colorful console(each log type is mapped to a color!)

KNOWN ISSUES

1. the quickLog.printX(msgs) methods do not give the proper line number and and file path.

  • I think this is a limitation of c# as paramters with the params key word have to be at the end of the paramaters... but so do optional paramaters.
    • I don't think I can fix this without doing some funky stuff with... maybe method overloading? I don't know..

USAGE

If you want a quick look through of usage, you can just look at this example script which is the source code to the other .csproj in this repository. However if you want a more indepth explanation we can start with,

First with logging messages to console

there are a few ways to log various kinds of messages. You could add logs to a built in list as so;

quickLog.error("This is an error message").AddToList();
quickLog.warning("This is a warning message").AddToList();
quickLog.info("This is an info message").AddToList();
quickLog.debug("This is a debug message").AddToList();

Log.List.Print();

But I found this only gave improvements for large amount of logs, so if you dont have that many you can just log normally. Heres an example that demonstrates as such but also show's making custom logs;

new Log("Custom log message", 1, Log.Type.error).print();
new Log("Custom log message", 1, Log.Type.warning).print();
quickLog.info("informatic message").print();
quickLog.debug("debug message").print();

Or if you don't wanna type too much you can just do this;

quickLog.printInfo("as so");

The list

you shouldn't use the list all too often, but there are some methods for it.

Log.List.SortByAmount();
Log.List.SortByMsg();
Log.List.SortByType();

Really this is just a side effect of how I decided to print multiple log's that I decided to add some functionality for

Along with logging to console

you can also log Exceptions(which get printed to both console AND to a file), or to a file. This looks as so;

someLog.writeToFile("C:\\exampleLogToFile.txt", true); // this is global path
someLog.writeToFile("exampleLogToFile.txt"); // this is relative path
someLog.writeToFile("exampleLogToFile.txt", false); // this is also relative path

and with exceptions;

Log exceptionLog = quickLog.Error("Uh oh, something went wrong!");
exceptionLog.Exception(); // this will also write to the file "!Exception on {MM-dd} at {HH;mm}" in the same folder as your compiled project

Lastly, time

The Timer class allows you to measure elapsed time; mostly for benchmarking.

Timer.start();
Console.WriteLine($"timer is running, started at {Timer.getStartTime}");
Console.WriteLine($"at {Timer.currTimeMS} milliseconds : {Timer.currTimeS} seconds");
stop();
Timer.start();
Timer.printCurrMs();
Timer.printCurrS();
#if secondsExample
  Timer.printS();
#else
  Timer.printMs();
#endif

PLANS ON FORWARD

Not much on planned implementations for now, but I do plan on adding improvements I may see and adding some new features. Updates probably wont be too frequent as this is just something I decided to make for myself and mostly myself.

Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net7.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.6 152 11/10/2023
1.1.5 141 11/3/2023
1.1.4 143 10/31/2023
1.1.3 169 10/28/2023 1.1.3 is deprecated because it has critical bugs.
1.0.8 182 10/24/2023
1.0.3 157 10/12/2023

Changed some small things, removed printSameLine for end paramater in print() kinda like python's print(). also made FormatLog public as I accidently had it private