Increase chunk size to send fewer messages.
Fixed logging lock (causes color issues in parallel env)
This commit is contained in:
parent
f912b9db8f
commit
a55af9f667
@ -1,9 +1,12 @@
|
||||
local secretToken = "$TOKEN"
|
||||
local connectionUri = "$HOST"
|
||||
local waitSeconds = 5
|
||||
-- https://github.com/cc-tweaked/CC-Tweaked/blob/9cf70b10effeeed23e0e9c537bbbe0b2ff0d1a0f/src/main/java/dan200/computercraft/core/apis/http/options/AddressRule.java#L29
|
||||
-- Chunk size must be less than packet size (type reply, success, chunkids, content: chunk) 16 kb for buffer
|
||||
local maxMessageSize = (128 - 16) * 1024
|
||||
|
||||
local function chunkString(value, chunkSize)
|
||||
if not chunkSize then chunkSize = 10000 end
|
||||
if not chunkSize then chunkSize = maxMessageSize end
|
||||
local length = value:len()
|
||||
local total = math.ceil(length / chunkSize)
|
||||
local chunks = {}
|
||||
|
@ -274,21 +274,22 @@ public class Program : IDisposable, ICommandHandler<ResponseType>, IUserRoleMana
|
||||
}
|
||||
|
||||
public static void Log(LogMessage msg) {
|
||||
var oldColor = Console.ForegroundColor;
|
||||
try {
|
||||
Console.ForegroundColor = msg.Severity switch {
|
||||
LogSeverity.Critical => ConsoleColor.Magenta,
|
||||
LogSeverity.Error => ConsoleColor.Red,
|
||||
LogSeverity.Warning => ConsoleColor.Yellow,
|
||||
LogSeverity.Info => ConsoleColor.White,
|
||||
LogSeverity.Verbose => ConsoleColor.Blue,
|
||||
LogSeverity.Debug => ConsoleColor.DarkBlue,
|
||||
_ => ConsoleColor.Cyan,
|
||||
};
|
||||
lock (LogLock)
|
||||
lock (LogLock) {
|
||||
var oldColor = Console.ForegroundColor;
|
||||
try {
|
||||
Console.ForegroundColor = msg.Severity switch {
|
||||
LogSeverity.Critical => ConsoleColor.Magenta,
|
||||
LogSeverity.Error => ConsoleColor.Red,
|
||||
LogSeverity.Warning => ConsoleColor.Yellow,
|
||||
LogSeverity.Info => ConsoleColor.White,
|
||||
LogSeverity.Verbose => ConsoleColor.Blue,
|
||||
LogSeverity.Debug => ConsoleColor.DarkBlue,
|
||||
_ => ConsoleColor.Cyan,
|
||||
};
|
||||
Console.WriteLine(msg.ToString());
|
||||
} finally {
|
||||
Console.ForegroundColor = oldColor;
|
||||
} finally {
|
||||
Console.ForegroundColor = oldColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user