mirror of
https://github.com/wiz0u/WTelegramClient.git
synced 2026-04-04 14:07:41 +00:00
Fix risk of having only WTelegram.session.tmp if killing the program in the middle of Delete/Move
(that's what File.Replace was trying to avoid!!)
This commit is contained in:
parent
a7fcbf60fa
commit
4739c9f539
2 changed files with 9 additions and 12 deletions
17
EXAMPLES.md
17
EXAMPLES.md
|
|
@ -364,22 +364,19 @@ client.TcpHandler = async (address, port) =>
|
|||
By default, WTelegramClient logs are displayed on the Console screen.
|
||||
If you are not in a Console app or don't want the logs on screen, you can redirect them as you prefer:
|
||||
|
||||
* Log to VS Output debugging pane in addition to default Console screen logging:
|
||||
```csharp
|
||||
// • Log to VS Output debugging pane in addition to default Console screen logging:
|
||||
WTelegram.Helpers.Log += (lvl, str) => System.Diagnostics.Debug.WriteLine(str);
|
||||
```
|
||||
* Log to file in replacement of default Console screen logging:
|
||||
```csharp
|
||||
|
||||
// • Log to file in replacement of default Console screen logging:
|
||||
WTelegram.Helpers.Log = (lvl, str) => File.AppendAllText("WTelegram.log", str + Environment.NewLine);
|
||||
```
|
||||
* More efficient example with a static variable and detailed logging to file:
|
||||
```csharp
|
||||
|
||||
// • More efficient example with a static variable and detailed logging to file:
|
||||
static StreamWriter WTelegramLogs = new StreamWriter("WTelegram.log", true, Encoding.UTF8) { AutoFlush = true };
|
||||
...
|
||||
WTelegram.Helpers.Log = (lvl, str) => WTelegramLogs.WriteLine($"{DateTime.Now:yyyy-MM-dd HH:mm:ss} [{"TDIWE!"[lvl]}] {str}");
|
||||
```
|
||||
* In an ASP.NET service, you will typically send logs to a `ILogger`:
|
||||
```csharp
|
||||
|
||||
// • In an ASP.NET service, you will typically send logs to a `ILogger`:
|
||||
WTelegram.Helpers.Log = (lvl, str) => _logger.Log((LogLevel)lvl, str);
|
||||
```
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue