public void Sample() { var client = ClientHelper.GetSdkClient(); LogEventManager.Verbose("This is a verbose message."); LogEventManager.Debug("This is a debug message."); LogEventManager.Info("This is a info message."); LogEventManager.Warn("This is a info message."); LogEventManager.Error("This is an error message.", new Sdk.Common.MetrikException("This is an ERROR exception test.")); LogEventManager.Fatal("This is a fatal message", new Sdk.Common.MetrikException("This is a FATAL exception test.")); // This is for checking if the logs are populated properly for each event type Assert.IsTrue(true); }
/// <summary> /// Processes the resultData and extracts the status code /// </summary> /// <param name="resultData"></param> /// <param name="targetUrl"></param> /// <param name="statusCode"></param> /// <returns></returns> public static JObject ProcessResultData(JObject resultData, string targetUrl, HttpMethod method) { var statusCode = HttpStatusCode.NotFound; if (resultData == null) { LogEventManager.Warn(GenerateMessage("Http response returned null.", null, targetUrl, method)); statusCode = HttpStatusCode.ExpectationFailed; return(null); } JObject jData = resultData; try { if (jData != null) { if (jData["meta"] != null) { if (jData["meta"]["status"] != null) { statusCode = (HttpStatusCode)Enum.Parse(typeof(HttpStatusCode), ((int)jData["meta"]["status"]).ToString()); if (!IsAffirmativeStatusCode(statusCode)) { LogEventManager.Warn(GenerateMessage("JSON response did not return an affirmative response.", resultData, targetUrl, method)); } else { LogEventManager.Verbose(GenerateMessage(string.Empty, resultData, targetUrl, method)); } } else { LogEventManager.Warn(GenerateMessage("JSON response did not define 'status' (HttpStatusCode) on the 'meta' node.", resultData, targetUrl, method)); } } else { LogEventManager.Warn(GenerateMessage("JSON response did not define 'meta'.", resultData, targetUrl, method)); } } else { LogEventManager.Warn(GenerateMessage("Unable to preprocess the returned data because it could not be cast to a JSON Object.", resultData, targetUrl, method)); } } catch (Exception ex) { if (jData != null) { LogEventManager.Error(GenerateMessage("Error processing the JSON result.", resultData, targetUrl, method), ex); } else { LogEventManager.Error("Error processing the JSON result.", ex); } } return(jData); }