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 secretToken = "$TOKEN"
|
||||||
local connectionUri = "$HOST"
|
local connectionUri = "$HOST"
|
||||||
local waitSeconds = 5
|
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)
|
local function chunkString(value, chunkSize)
|
||||||
if not chunkSize then chunkSize = 10000 end
|
if not chunkSize then chunkSize = maxMessageSize end
|
||||||
local length = value:len()
|
local length = value:len()
|
||||||
local total = math.ceil(length / chunkSize)
|
local total = math.ceil(length / chunkSize)
|
||||||
local chunks = {}
|
local chunks = {}
|
||||||
|
@ -274,6 +274,7 @@ public class Program : IDisposable, ICommandHandler<ResponseType>, IUserRoleMana
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void Log(LogMessage msg) {
|
public static void Log(LogMessage msg) {
|
||||||
|
lock (LogLock) {
|
||||||
var oldColor = Console.ForegroundColor;
|
var oldColor = Console.ForegroundColor;
|
||||||
try {
|
try {
|
||||||
Console.ForegroundColor = msg.Severity switch {
|
Console.ForegroundColor = msg.Severity switch {
|
||||||
@ -285,12 +286,12 @@ public class Program : IDisposable, ICommandHandler<ResponseType>, IUserRoleMana
|
|||||||
LogSeverity.Debug => ConsoleColor.DarkBlue,
|
LogSeverity.Debug => ConsoleColor.DarkBlue,
|
||||||
_ => ConsoleColor.Cyan,
|
_ => ConsoleColor.Cyan,
|
||||||
};
|
};
|
||||||
lock (LogLock)
|
|
||||||
Console.WriteLine(msg.ToString());
|
Console.WriteLine(msg.ToString());
|
||||||
} finally {
|
} finally {
|
||||||
Console.ForegroundColor = oldColor;
|
Console.ForegroundColor = oldColor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected virtual void Dispose(bool disposing) {
|
protected virtual void Dispose(bool disposing) {
|
||||||
if (!disposedValue) {
|
if (!disposedValue) {
|
||||||
|
Loading…
Reference in New Issue
Block a user