Skip to content

Commit ef11136

Browse files
committed
saving progress
1 parent 2125ecc commit ef11136

File tree

3 files changed

+52
-132
lines changed

3 files changed

+52
-132
lines changed

ComfiUINodes/Handlers/RunFunction.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,7 @@ public static void RunFunction(HttpListenerContext ctx)
6060
//var content = new MultipartContent("form-data", contentType.Boundary);
6161
//var multiData = new MultipartFormDataContent(contentType.Boundary);
6262
//multiData.
63-
// TODO create job
64-
// ughh.. logging is not going to work as is..
65-
// maybe change IFunction to have an IFunctionContext object with all of the bits attached
66-
// (basically the Job object) and include logging
63+
TODO create job
6764
// fs.Write(sep,0,sep.Length);
6865
// var help = $"{contentType.Name} {contentType.MediaType} {contentType.Boundary}";
6966
// var ct = Encoding.UTF8.GetBytes(help + "\r\n");

Core/Logging/Log.cs

Lines changed: 0 additions & 128 deletions
This file was deleted.

Core/Logging/LogToConsole.cs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
namespace ImageFunctions.Core.Logging;
2+
3+
public sealed class LogToConsole : ICoreLog
4+
{
5+
public bool BeVerbose { get; set; }
6+
7+
public void Message(string m)
8+
{
9+
Console.ResetColor();
10+
Console.WriteLine(m);
11+
}
12+
13+
public void Info(string m)
14+
{
15+
if(BeVerbose) {
16+
WithColor($"I: {m}", ConsoleColor.Gray);
17+
}
18+
}
19+
20+
public void Warning(string m)
21+
{
22+
WithColor($"W: {m}", ConsoleColor.Yellow, true);
23+
}
24+
25+
public void Error(string m, Exception e = null)
26+
{
27+
string se = e == null ? "" : $" : {e.Message}";
28+
WithColor($"E: {m}{se}", ConsoleColor.Red, true);
29+
}
30+
31+
public void Debug(string m)
32+
{
33+
#if DEBUG
34+
WithColor($"D: {m}", ConsoleColor.DarkGray);
35+
#endif
36+
}
37+
38+
void WithColor(string m, ConsoleColor color, bool error = false)
39+
{
40+
//using try-finally to make sure the console color gets reset
41+
// otherwise stopping the program (ctrl-c) can leave the console with a leftover color
42+
try {
43+
Console.ForegroundColor = color;
44+
var tw = error ? Console.Error : Console.Out;
45+
tw.WriteLine(m);
46+
}
47+
finally {
48+
Console.ResetColor();
49+
}
50+
}
51+
}

0 commit comments

Comments
 (0)