summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2009-12-21 20:26:46 -0800
committerAndrew Arnott <andrewarnott@gmail.com>2009-12-21 20:26:46 -0800
commite7a6412d8bf613f2a679bb8b3ad4fbd7cf1b81f7 (patch)
tree0a9f7f474b3ce04d4098ec1576e523c9307166b1 /src
parentd6f93f8ae827f6778c586dbcee21124ef6bbe47d (diff)
downloadDotNetOpenAuth-e7a6412d8bf613f2a679bb8b3ad4fbd7cf1b81f7.zip
DotNetOpenAuth-e7a6412d8bf613f2a679bb8b3ad4fbd7cf1b81f7.tar.gz
DotNetOpenAuth-e7a6412d8bf613f2a679bb8b3ad4fbd7cf1b81f7.tar.bz2
Pulled out the log demuxer method.
Diffstat (limited to 'src')
-rw-r--r--src/DotNetOpenAuth/Reporting.cs38
1 files changed, 29 insertions, 9 deletions
diff --git a/src/DotNetOpenAuth/Reporting.cs b/src/DotNetOpenAuth/Reporting.cs
index a32945a..1bd3730 100644
--- a/src/DotNetOpenAuth/Reporting.cs
+++ b/src/DotNetOpenAuth/Reporting.cs
@@ -333,15 +333,7 @@ namespace DotNetOpenAuth {
using (var responseReader = response.GetResponseReader()) {
string line = responseReader.ReadLine();
if (line != null) {
- if (line.StartsWith("INFO ")) {
- Logger.Library.Info(line.Substring(5));
- } if (line.StartsWith("WARN ")) {
- Logger.Library.Warn(line.Substring(5));
- } else if (line.StartsWith("ERROR ")) {
- Logger.Library.Warn(line.Substring(6));
- } else if (line.StartsWith("FATAL ")) {
- Logger.Library.Fatal(line.Substring(6));
- }
+ DemuxLogMessage(line);
}
}
}
@@ -365,6 +357,34 @@ namespace DotNetOpenAuth {
}
/// <summary>
+ /// Interprets the reporting response as a log message if possible.
+ /// </summary>
+ /// <param name="line">The line from the HTTP response to interpret as a log message.</param>
+ private static void DemuxLogMessage(string line) {
+ if (line != null) {
+ string[] parts = line.Split(new char[] { ' ' }, 2);
+ if (parts.Length == 2) {
+ string level = parts[0];
+ string message = parts[1];
+ switch (level) {
+ case "INFO":
+ Logger.Library.Info(message);
+ break;
+ case "WARN":
+ Logger.Library.Warn(message);
+ break;
+ case "ERROR":
+ Logger.Library.Error(message);
+ break;
+ case "FATAL":
+ Logger.Library.Fatal(message);
+ break;
+ }
+ }
+ }
+ }
+
+ /// <summary>
/// Called by every internal/public method on this class to give
/// periodic operations a chance to run.
/// </summary>