File tree Expand file tree Collapse file tree 3 files changed +28
-1
lines changed Expand file tree Collapse file tree 3 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -4,8 +4,11 @@ Library for Stackify users to integrate Stackify in to their projects. Provides
44
55** Important links:**
66- [ Stackify homepage] ( http://www.stackify.com )
7- - [ Stackify documentation site] ( http://docs .stackify.com/s/3095/m/7787 )
7+ - [ Stackify documentation site] ( http://support .stackify.com/hc/en-us/categories/200398739-Errors-Logs )
88- [ NuGet packages] ( https://www.nuget.org/packages?q=Stackify )
9+ - [ Best practices for logging with C#] ( https://stackify.com/csharp-logging-best-practices/ )
10+ - [ Why you should use tags in your logs] ( https://stackify.com/get-smarter-log-management-with-log-tags/ )
11+
912
1013** Read me sections:**
1114- [ Basics] ( #basics )
Original file line number Diff line number Diff line change 44using System . Linq ;
55using System . Net ;
66using System . Text ;
7+ using System . Threading ;
78using System . Threading . Tasks ;
89//using System.Web.Configuration;
910using Newtonsoft . Json ;
@@ -123,6 +124,11 @@ public bool ErrorShouldBeSent(StackifyError error)
123124 return governor . ErrorShouldBeSent ( error ) ;
124125 }
125126
127+
128+
129+ private static long _lastEpochMs = 0 ;
130+ private static int _millisecondCount = 0 ;
131+
126132 public void QueueMessage ( LogMsg msg )
127133 {
128134 if ( msg == null ) return ;
@@ -139,6 +145,21 @@ public void QueueMessage(LogMsg msg)
139145 isError = 1 ;
140146 }
141147
148+ // works on the assumption that the epochMS will always be incrementing as it reaches this point
149+ if ( _lastEpochMs < msg . EpochMs )
150+ {
151+ // reset counter if we are no longer in the same ms
152+ //https://msdn.microsoft.com/en-us/library/system.threading.interlocked_methods(v=vs.110).aspx
153+ Interlocked . Exchange ( ref _lastEpochMs , msg . EpochMs ) ;
154+ Interlocked . Exchange ( ref _millisecondCount , 0 ) ;
155+ msg . Order = 0 ;
156+ }
157+ else if ( _lastEpochMs == msg . EpochMs )
158+ {
159+ msg . Order = Interlocked . Increment ( ref _millisecondCount ) ;
160+ }
161+ // else defaulted to 0
162+
142163 //Used by Stackify profiler only
143164 if ( Logger . PrefixEnabled ( ) )
144165 {
Original file line number Diff line number Diff line change @@ -99,6 +99,9 @@ public LogMsg()
9999 [ JsonProperty ]
100100 public List < string > Tags { get ; set ; }
101101
102+ [ JsonProperty ]
103+ public int Order { get ; set ; }
104+
102105 [ JsonIgnore ]
103106 public LogMsgGroup AppDetails { get ; set ; }
104107
You can’t perform that action at this time.
0 commit comments