|
1 | | -namespace Mediocre { |
2 | | - using System; |
3 | | - using System.Threading.Tasks; |
| 1 | +namespace Mediocre; |
| 2 | +using System; |
| 3 | +using System.Threading.Tasks; |
4 | 4 |
|
5 | | - using Newtonsoft.Json; |
| 5 | +using Newtonsoft.Json; |
6 | 6 |
|
7 | | - using YeelightAPI; |
| 7 | +using YeelightAPI; |
8 | 8 |
|
9 | | - public static class Log { |
10 | | - public static bool Verbose; |
| 9 | +public static class Log { |
| 10 | + public static bool Verbose; |
11 | 11 |
|
12 | | - public static void Msg(FormattableString msg) => Console.WriteLine(msg); |
| 12 | + public static void Msg(FormattableString msg) => Console.WriteLine(msg); |
13 | 13 |
|
14 | | - public static void Dbg(FormattableString msg) { |
15 | | - if (!Verbose) return; |
| 14 | + public static void Dbg(FormattableString msg) { |
| 15 | + if (!Verbose) return; |
16 | 16 |
|
17 | | - using (ConsoleWith.FG(ConsoleColor.DarkGray)) |
18 | | - Console.WriteLine(msg); |
19 | | - } |
20 | | - |
21 | | - public static void Err(FormattableString msg) { |
22 | | - using (ConsoleWith.FG(ConsoleColor.DarkRed)) |
23 | | - Console.WriteLine(msg); |
24 | | - } |
| 17 | + using (ConsoleWith.FG(ConsoleColor.DarkGray)) |
| 18 | + Console.WriteLine(msg); |
| 19 | + } |
25 | 20 |
|
26 | | - public static void Dbg(object sender, NotificationReceivedEventArgs e) { |
27 | | - if (Verbose) Dbg($"device received: {JsonConvert.SerializeObject(e.Result)}"); |
28 | | - } |
| 21 | + public static void Err(FormattableString msg) { |
| 22 | + using (ConsoleWith.FG(ConsoleColor.DarkRed)) |
| 23 | + Console.WriteLine(msg); |
| 24 | + } |
29 | 25 |
|
30 | | - public static void Err(object sender, UnhandledExceptionEventArgs e) |
31 | | - => Err($"device error: {e}"); |
| 26 | + public static void Dbg(object sender, NotificationReceivedEventArgs e) { |
| 27 | + if (Verbose) Dbg($"device received: {JsonConvert.SerializeObject(e.Result)}"); |
32 | 28 | } |
33 | 29 |
|
34 | | - public static class CmdResultExt { |
35 | | - public static async Task Log(this Task<bool> cmdResult, FormattableString msg) { |
36 | | - if (await cmdResult) |
37 | | - Mediocre.Log.Dbg(msg); |
38 | | - else |
39 | | - Mediocre.Log.Err($"{msg} failed."); |
40 | | - } |
| 30 | + public static void Err(object sender, UnhandledExceptionEventArgs e) |
| 31 | + => Err($"device error: {e}"); |
| 32 | +} |
| 33 | + |
| 34 | +public static class CmdResultExt { |
| 35 | + public static async Task Log(this Task<bool> cmdResult, FormattableString msg) { |
| 36 | + if (await cmdResult) |
| 37 | + Mediocre.Log.Dbg(msg); |
| 38 | + else |
| 39 | + Mediocre.Log.Err($"{msg} failed."); |
41 | 40 | } |
42 | 41 | } |
0 commit comments