-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Grand Unified Console [WIP] #8
Grand Unified Console [WIP] #8
Conversation
10 hours of laptop battery and a flight from Oslo to Brisbane later... Log.Logger = new LoggerConfiguration()
.MinimumLevel.Verbose()
.WriteTo.Console()
.CreateLogger(); As you can see, the default console output now uses the "literate" theme, and has an updated Here's what the template looks like behind the scenes: "[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}" Original styleThe following configuration produces the same output as the original Serilog.Sinks.Console: Log.Logger = new LoggerConfiguration()
.MinimumLevel.Verbose()
.WriteTo.Console(
outputTemplate: "[{Timestamp:HH:mm:ss} {Level:u3}] {Message}{NewLine}{Exception}",
theme: ConsoleTheme.None)
.CreateLogger(); Notice the omission of ANSI outputANSI themes are supported: Log.Logger = new LoggerConfiguration()
.MinimumLevel.Verbose()
.WriteTo.Console(theme: AnsiConsoleTheme.Literate)
.CreateLogger(); On Win 10, these seem to work from the PowerShell console only, I can't get Visual Studio's F5 experience to work with it (just shows garbage). The 'literate' theme doesn't transfer to 16-color ANSI very well, but it's passable. OtherCustom output via formatters such as Themes can be created by constructing instances of the The design of To do (maybe post-PR, if anyone's keen to get their hands on this and try building some themes, first ;-)):
|
VS Code-style theme is in; going to call it a day for now. Will add a couple of tests to get the ball rolling, then call this "done". |
We should detect OS and version and P/Invoke Kernel32's SetConsoleMode to enable VT100 sequences on Windows 10. That should make conhost respect the CSI codes instead of writing garbage. I can PR this later if you want. |
Should we provide a few sample projects, given the increased options available? |
|
Woot! Thanks @merbla 👍 |
@merbla tried the |
|
👍 ... |
|
|
Success! Though now I am wondering if we can come up with a better theme than that..... :-) |
Are we thinking this is a |
|
||
<PropertyGroup> | ||
<Description>A Serilog sink that writes log events to the console/terminal.</Description> | ||
<VersionPrefix>3.0.0</VersionPrefix> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@merbla yep :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
soz missed that one. I was looking for project.json
😜
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still find myself doing that, too.
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Serilog" Version="2.5.0-dev-00842" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't forget to circle back to this, post 2.5
@nblumhardt when you are comfortable, lets get this in and built for |
Okay, close enough to "tested" - just exercises the renderers by switching off the theme and running them through the Serilog tests. There are actually a couple of other potentially-breaking changes here; I think they're reasonably harmless, but ... full disclosure :-)
To get 100% full fidelity with version 2 of this sink, you can use: .WriteTo.Console(new MessageTemplateTextFormatter(
"{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level}] {Message}{NewLine}{Exception}",
null)) This will bypass the custom/themed formatters and use Serilog's built-in formatting, which is as-yet unchanged (I'd like to discuss taking the C#-style object and dictionary syntax back there, too, in another thread :-)). One tiny dependency version change, then I'll hit the button! Thoughts on the above welcome. |
Just a thought; what happens with ANSI escape codes when standard output is redirected? Should we also check |
Oh, sorry, didn't notice it. Awesome! 😁 |
The VS Code terminal should support ANSI escape codes out of the box. Is that output from a running app? |
fixed removing using
yes |
Started work on #7 - just a very basic merge of Serilog.Sinks.Console and Serilog.Sinks.LiterateConsole at this point.