public void Emit(LogEvent logEvent) { var message = new KatoMessage() { From = Name, Renderer = Renderer, Color = GetColor(logEvent.Level), Text = logEvent.RenderMessage(), }; SendRequest(message); }
/// <summary> /// POST a message to the Kato room. /// </summary> /// <param name="body"></param> private void SendRequest(KatoMessage message) { var body = JsonConvert.SerializeObject(message, _settings); var request = WebRequest.Create(RoomUrl); request.Method = "POST"; request.ContentType = "application/json"; using (var stream = request.GetRequestStream()) { var bytes = Encoding.UTF8.GetBytes(body); stream.Write(bytes, 0, bytes.Length); } var response = request.GetResponse(); // TODO: Handle response return; }