-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
61 lines (52 loc) · 2.11 KB
/
Program.cs
File metadata and controls
61 lines (52 loc) · 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
using System;
using System.Diagnostics;
using System.Threading;
using Microsoft.Extensions.Logging;
using nanoFramework.Logging;
using nanoFramework.Logging.Debug;
using nanoFramework.Logging.Serial;
using Windows.Devices.SerialCommunication;
using nanoFramework.Hardware.Esp32;
namespace DependencyProblemTest
{
public class Program
{
private static DebugLogger _logger;
public static void Main()
{
Debug.WriteLine("Hello from Debug.WriteLine!");
_logger = new DebugLogger("Example");
_logger.MinLogLevel = LogLevel.Trace;
_logger.LogInformation("Hello from nanoFramework!");
_logger.Log(LogLevel.Information, 0, "this is state???", null, null);
_logger.LogTrace("Trace: the Debug Logger is initialized");
_logger.LogInformation($"Logger name is: {_logger.LoggerName}, you can use that to trace which component is used");
_logger.LogInformation("The next call to the class will log as well");
_logger.LogInformation("For this component, we're using the Logger Factory pattern. It will use the debugger as well");
LogDispatcher.LoggerFactory = new DebugLoggerFactory();
MyTestComponent test = new MyTestComponent();
do
{
test.DoSomeLogging();
} while (true);
//Thread.Sleep(Timeout.Infinite);
// Browse our samples repository: https://github.com/nanoframework/samples
// Check our documentation online: https://docs.nanoframework.net/
// Join our lively Discord community: https://discord.gg/gCyBu8T
}
}
internal class MyTestComponent
{
private readonly ILogger _logger;
public MyTestComponent()
{
_logger = this.GetCurrentClassLogger();
}
public void DoSomeLogging()
{
_logger.LogInformation("An informative message");
_logger.LogError("An error situation");
_logger.LogWarning(new Exception("Something is not supported"), "With exception context");
}
}
}