private void Transport_OnInstanceLog(long instanceId, DeltaLogLevel logLevel, string topic, string message) { //Make sure this matches our instance if (this.instanceId != instanceId) { return; } //Determine color string color = "black"; switch (logLevel) { case DeltaLogLevel.Debug: color = "black"; break; case DeltaLogLevel.Low: color = "#0394fc"; break; case DeltaLogLevel.Medium: color = "#fca903"; break; case DeltaLogLevel.High: color = "#fa3737"; break; case DeltaLogLevel.Alert: color = "#fa37ea"; break; } //Log WriteString($"<div style=\"display:flex;margin-top:6px;\"><div style=\"margin-right: 10px;white-space: nowrap;\"><span style=\"background-color:{color};color:white;border-radius: 5px;padding: 2px 6px;\">{logLevel.ToString().ToUpper()}</span> <u style=\"color:{color};\">{HttpUtility.HtmlEncode(topic)}</u></div><div>{HttpUtility.HtmlEncode(message).Replace("\n", "<br>")}</div></div>"); }
public void Log(string topic, string message, DeltaLogLevel level) { //Log to stdout if (loggingEnabled) { //Translate level to console color switch (level) { case DeltaLogLevel.Debug: Console.ForegroundColor = ConsoleColor.Cyan; break; case DeltaLogLevel.Low: Console.ForegroundColor = ConsoleColor.White; break; case DeltaLogLevel.Medium: Console.ForegroundColor = ConsoleColor.Yellow; break; case DeltaLogLevel.High: Console.ForegroundColor = ConsoleColor.Red; break; case DeltaLogLevel.Alert: Console.ForegroundColor = ConsoleColor.White; Console.BackgroundColor = ConsoleColor.Red; break; } //Write Console.WriteLine($"[{topic}] {message}"); //Reset Console.ForegroundColor = ConsoleColor.White; Console.BackgroundColor = ConsoleColor.Black; } //Remote log if (net != null && (loggingEnabled || (int)level >= (int)DeltaLogLevel.High) && !topic.StartsWith("Init") && !topic.StartsWith("RouterIO")) { net.SendLogCommand(topic, message, level); } }
public void SendLogCommand(string topic, string message, DeltaLogLevel level) { //Calculate lengths int topicLen = Encoding.UTF8.GetByteCount(topic); int messageLen = Encoding.UTF8.GetByteCount(message); //Open buffer and write byte[] buffer = new byte[4 + 4 + topicLen + 4 + messageLen]; BitConverter.GetBytes((int)level).CopyTo(buffer, 0); BitConverter.GetBytes(topicLen).CopyTo(buffer, 4); Encoding.UTF8.GetBytes(topic).CopyTo(buffer, 8); BitConverter.GetBytes(messageLen).CopyTo(buffer, 8 + topicLen); Encoding.UTF8.GetBytes(message).CopyTo(buffer, 8 + topicLen + 4); //Send io.SendMessage(OPCODE_SYS_LOG, buffer); }
public void Log(string topic, string msg, DeltaLogLevel level) { baseLogger.Log("BaseRouterIO-" + topic, msg, level); }
public void Log(string topic, string message, DeltaLogLevel level) { Console.WriteLine($"[{level.ToString().ToUpper().PadLeft(6, ' ')}] [{topic}] {message}"); }
public void Log(string topic, string message, DeltaLogLevel level) { baseLogger.Log("RouterServerIO-" + topic, message, level); }