Permalink
Browse files

The log handler is now using fast binary serialization

  • Loading branch information...
1 parent fe01963 commit 84df15966d1cf32874e249d65295c89d37973b8c @GWBasic committed Jun 25, 2012
Showing with 34 additions and 0 deletions.
  1. +34 −0 Server/ObjectCloud.Disk/Factories/LogHandlerFactory.cs
@@ -6,6 +6,7 @@
using System.IO;
using ObjectCloud.Common;
+using ObjectCloud.Common.StreamEx;
using ObjectCloud.Common.Threading;
using ObjectCloud.Disk.FileHandlers;
using ObjectCloud.Interfaces.Disk;
@@ -86,5 +87,38 @@ public override void Stop()
delegateQueues.Enqueue(delegateQueue);
}
}
+
+ private LoggingEvent Deserialize(Stream stream)
+ {
+ return new LoggingEvent()
+ {
+ Classname = stream.ReadString(),
+ ExceptionClassname = stream.ReadString(),
+ ExceptionMessage = stream.ReadString(),
+ ExceptionStackTrace = stream.ReadString(),
+ Level = (LoggingLevel)stream.Read<int>(),
+ Message = stream.ReadString(),
+ RemoteEndPoint = stream.ReadString(),
+ SessionId = stream.ReadNullable<ID<ISession, Guid>>(),
+ ThreadId = stream.Read<int>(),
+ TimeStamp = new DateTime(stream.Read<long>()),
+ UserId = stream.ReadNullable<ID<IUserOrGroup, Guid>>()
+ };
+ }
+
+ private void Serialize(Stream stream, LoggingEvent loggingEvent)
+ {
+ stream.Write(loggingEvent.Classname);
+ stream.Write(loggingEvent.ExceptionClassname);
+ stream.Write(loggingEvent.ExceptionMessage);
+ stream.Write(loggingEvent.ExceptionStackTrace);
+ stream.Write((int)loggingEvent.Level);
+ stream.Write(loggingEvent.Message);
+ stream.Write(loggingEvent.RemoteEndPoint);
+ stream.WriteNullable(loggingEvent.SessionId);
+ stream.Write(loggingEvent.ThreadId);
+ stream.Write(loggingEvent.TimeStamp.Ticks);
+ stream.WriteNullable(loggingEvent.UserId);
+ }
}
}

0 comments on commit 84df159

Please sign in to comment.