Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

updated Timestamp property to optionally convert to UTC

  • Loading branch information...
commit ceb1f57c9413512a6a6c85969f142984639c56a1 1 parent 04f28b7
dave authored
View
BIN  loggr-dotnet/bin/loggr-dotnet.dll
Binary file not shown
View
24 loggr-dotnet/loggr-dotnet/FluentEvent.cs
@@ -189,14 +189,30 @@ public virtual T User(string FormatString, params object[] FormatArguments)
}
/// <summary>
- /// Assigns the Loggr.Event's Timestamp property (Optional timestamp to indicate when an event was created. This is typically not needed unless your application
- /// is queuing events for later posting to Loggr)
+ /// Assigns the Loggr.Event's Timestamp property.
+ /// This is used to indicate when an event was created. This is typically not needed unless your application
+ /// is queuing events for later posting to Loggr.
/// </summary>
- /// <param name="Timestamp"></param>
+ /// <param name="Timestamp">When the event occured, in local time. It will be converted to Coordinated Universal Time (UTC) to be sent to Loggr.</param>
/// <returns></returns>
public virtual T Timestamp(DateTime Timestamp)
{
- this.Event.Timestamp = Timestamp;
+ return this.Timestamp(Timestamp, true);
+ }
+
+ /// <summary>
+ /// Assigns the Loggr.Event's Timestamp property.
+ /// This is used to indicate when an event was created. This is typically not needed unless your application
+ /// is queuing events for later posting to Loggr.
+ /// </summary>
+ /// <param name="Timestamp">When the event occured. </param>
+ /// <param name="convertToUTC">Convert the timestamp to Coordinated Universal Time (UTC) which is required by Loggr</param>
+ /// <returns></returns>
+ public virtual T Timestamp(DateTime Timestamp, bool convertToUTC)
+ {
+ if (convertToUTC)
+ this.Event.Timestamp = Timestamp.ToUniversalTime();
+ else this.Event.Timestamp = Timestamp;
return this as T;
}
View
7 loggr-dotnet/loggr-dotnet/LogClient.cs
@@ -282,7 +282,6 @@ protected string CreateEventQuerystring(Event eventObj)
AppendQuerystringNameValueList("tags", eventObj.Tags, ref qs, 200);
AppendQuerystringNameValue("source", eventObj.Source, ref qs, 200);
AppendQuerystringNameValue("user", eventObj.User, ref qs, 200);
- AppendQuerystringNameValueDate("time", eventObj.Timestamp, ref qs, 30);
if (eventObj.DataType == DataType.html)
{
AppendQuerystringNameValue("data", "@html" + Environment.NewLine + eventObj.Data, ref qs, 5120);
@@ -354,13 +353,13 @@ protected object AppendQuerystringNameValueDate(string name, DateTime? value, re
return querystring;
if (querystring.Length > 0)
querystring += "&";
- querystring += string.Format("{0}={1}", name, HttpUtility.UrlEncode(Cap(DateToUTCMilliseconds(value.Value).ToString(), length)));
+ querystring += string.Format("{0}={1}", name, HttpUtility.UrlEncode(Cap(DateToMilliseconds(value.Value).ToString(), length)));
return querystring;
}
- protected double DateToUTCMilliseconds(DateTime input)
+ protected double DateToMilliseconds(DateTime input)
{
- return (input.ToUniversalTime() - new DateTime(1970,1,1,0,0,0)).TotalMilliseconds;
+ return (input - new DateTime(1970, 1, 1, 0, 0, 0)).TotalMilliseconds;
}
protected string Cap(string input, int length)
View
2  loggr-dotnet/nuget/loggr-dotnet.nuspec
@@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>loggr-dotnet</id>
- <version>1.0.5</version>
+ <version>1.0.6</version>
<authors>Dave Weaver</authors>
<owners>Loggr</owners>
<projectUrl>http://loggr.net</projectUrl>
Please sign in to comment.
Something went wrong with that request. Please try again.