Skip to content

Commit 06fb4da

Browse files
committed
Logger cleanup
1 parent 7d54eb7 commit 06fb4da

File tree

5 files changed

+23
-14
lines changed

5 files changed

+23
-14
lines changed

Terminal.Gui/ConsoleDrivers/AnsiResponseParser/AnsiMouseParser.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public bool IsMouse (string? cur)
5252
Flags = GetFlags (buttonCode, terminator)
5353
};
5454

55-
Logging.Trace ($"{nameof (AnsiMouseParser)} handled as {input} mouse {m.Flags} at {m.Position}");
55+
//Logging.Trace ($"{nameof (AnsiMouseParser)} handled as {input} mouse {m.Flags} at {m.Position}");
5656

5757
return m;
5858
}

Terminal.Gui/ConsoleDrivers/V2/InputProcessor.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public void OnMouseEvent (MouseEventArgs a)
7979

8080
foreach (MouseEventArgs e in _mouseInterpreter.Process (a))
8181
{
82-
Logging.Trace ($"Mouse Interpreter raising {e.Flags}");
82+
// Logging.Trace ($"Mouse Interpreter raising {e.Flags}");
8383

8484
// Pass on
8585
MouseEvent?.Invoke (this, e);

UICatalog/UICatalog.cs

+10-7
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public class UICatalogApp
7474
private static Options _options;
7575
private static ObservableCollection<Scenario>? _scenarios;
7676

77-
private const string LOGFILE_LOCATION = "./logs";
77+
private const string LOGFILE_LOCATION = "logs";
7878
private static string _logFilePath = string.Empty;
7979
private static readonly LoggingLevelSwitch _logLevelSwitch = new ();
8080

@@ -171,7 +171,7 @@ private static int Main (string [] args)
171171
resultsFile.AddAlias ("--f");
172172

173173
// what's the app name?
174-
_logFilePath = $"{LOGFILE_LOCATION}/{Assembly.GetExecutingAssembly ().GetName ().Name}.log";
174+
_logFilePath = $"{LOGFILE_LOCATION}/{Assembly.GetExecutingAssembly ().GetName ().Name}";
175175
Option<string> debugLogLevel = new Option<string> ("--debug-log-level", $"The level to use for logging (debug console and {_logFilePath})").FromAmong (
176176
Enum.GetNames<LogLevel> ()
177177
);
@@ -1354,11 +1354,14 @@ private List<MenuItem []> CreateLoggingMenuItems ()
13541354
menuItems.Add (null!);
13551355

13561356
menuItems.Add (
1357-
new ()
1358-
{
1359-
Title = $"Log file: {_logFilePath}"
1360-
//CanExecute = () => false
1361-
});
1357+
new (
1358+
$"_Open Log Folder",
1359+
"",
1360+
() => OpenUrl (LOGFILE_LOCATION),
1361+
null,
1362+
null,
1363+
null
1364+
));
13621365

13631366
return menuItems.ToArray ()!;
13641367
}

docfx/docs/logging.md

+11-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
# Logging
22

3-
Logging has come to Terminal.Gui! You can now enable comprehensive logging of the internals of the libray. This can help diagnose issues with specific terminals, keyboard cultures and/or operating system specific issues.
3+
Logging has come to Terminal.Gui! You can now enable comprehensive logging of the internals of the library. This can help diagnose issues with specific terminals, keyboard cultures and/or operating system specific issues.
44

5-
To enable file logging you should set the static property `Logging.Logger` to an instance of `Microsoft.Extensions.Logging.ILogger`. If your program already uses logging you can provide a shared instance or instance from Dependency Injection (DI).
5+
To enable file logging you should set the static property `Logging.Logger` to an instance of `Microsoft.Extensions.Logging.ILogger`. If your program already uses logging you can provide a shared instance or instance from Dependency Injection (DI).
66

77
Alternatively you can create a new log to ensure only Terminal.Gui logs appear.
88

9-
Any logging framework will work (Serilog, NLog, Log4Net etc) but you should ensure you only log to File or UDP etc (i.e. not to console!).
9+
Any logging framework will work (Serilog, NLog, Log4Net etc) but you should ensure you don't log to the stdout console (File, Debug Output, or UDP etc... are all fine).
1010

11-
## Worked example with Serilog to file
11+
## UICatalog
12+
13+
UI Catalog has built-in UI for logging. It logs to both the debug console and a file. By default it only logs at the `Warning` level.
14+
15+
![UICatalog Logging](../images/UICatalog_Logging.png)
16+
17+
## Example with Serilog to file
1218

1319
Here is an example of how to add logging of Terminal.Gui internals to your program using Serilog file log.
1420

@@ -81,7 +87,7 @@ Example logs:
8187

8288
## Metrics
8389

84-
If you are finding that the UI is slow or unresponsive - or are just interested in performance metrics. You can see these by instaling the `dotnet-counter` tool and running it for your process.
90+
If you are finding that the UI is slow or unresponsive - or are just interested in performance metrics. You can see these by installing the `dotnet-counter` tool and running it for your process.
8591

8692
```
8793
dotnet tool install dotnet-counters --global

docfx/images/UICatalog_Logging.png

51.8 KB
Loading

0 commit comments

Comments
 (0)