Increase chunk size to send fewer messages.
Fixed logging lock (causes color issues in parallel env)
This commit is contained in:
		| @@ -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,21 +274,22 @@ public class Program : IDisposable, ICommandHandler<ResponseType>, IUserRoleMana | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static void Log(LogMessage msg) { |     public static void Log(LogMessage msg) { | ||||||
|         var oldColor = Console.ForegroundColor; |         lock (LogLock) { | ||||||
|         try { |             var oldColor = Console.ForegroundColor; | ||||||
|             Console.ForegroundColor = msg.Severity switch { |             try { | ||||||
|                 LogSeverity.Critical => ConsoleColor.Magenta, |                 Console.ForegroundColor = msg.Severity switch { | ||||||
|                 LogSeverity.Error => ConsoleColor.Red, |                     LogSeverity.Critical => ConsoleColor.Magenta, | ||||||
|                 LogSeverity.Warning => ConsoleColor.Yellow, |                     LogSeverity.Error => ConsoleColor.Red, | ||||||
|                 LogSeverity.Info => ConsoleColor.White, |                     LogSeverity.Warning => ConsoleColor.Yellow, | ||||||
|                 LogSeverity.Verbose => ConsoleColor.Blue, |                     LogSeverity.Info => ConsoleColor.White, | ||||||
|                 LogSeverity.Debug => ConsoleColor.DarkBlue, |                     LogSeverity.Verbose => ConsoleColor.Blue, | ||||||
|                 _ => ConsoleColor.Cyan, |                     LogSeverity.Debug => ConsoleColor.DarkBlue, | ||||||
|             }; |                     _ => ConsoleColor.Cyan, | ||||||
|             lock (LogLock) |                 }; | ||||||
|                 Console.WriteLine(msg.ToString()); |                 Console.WriteLine(msg.ToString()); | ||||||
|         } finally { |             } finally { | ||||||
|             Console.ForegroundColor = oldColor; |                 Console.ForegroundColor = oldColor; | ||||||
|  |             } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user