Beispiel #1
0
        public static int Write(BinaryWriter writer, DateTime dateTime, TraceEventType eventType, int tick,
			LogComponent component, string thread, string header, string message)
        {
            writer.Write(dateTime.ToBinary());
            writer.Write((int)eventType);
            writer.Write(tick);
            writer.Write((byte)component);
            writer.Write(thread);
            writer.Write(header);
            writer.Write(message);
            writer.Flush();
            return (int)writer.BaseStream.Position;
        }
Beispiel #2
0
        public static void Append(TraceEventType eventType, int tick, LogComponent component, string thread,
			string header, string message)
        {
            byte[] buffer = s_buffer;

            if (buffer == null)
                s_buffer = buffer = new byte[MaxPayload];

            var writer = s_writer;

            if (writer == null)
                s_writer = writer = new BinaryWriter(new MemoryStream(buffer));
            else
                writer.Seek(0, SeekOrigin.Begin);

            int len = LogEntry.Write(writer, DateTime.UtcNow, eventType, tick, component, thread, header, message);

            s_indexMutex.WaitOne();

            int idx = IncrementCurrentIndex();
            WriteArray(idx, buffer, len);

            s_indexMutex.ReleaseMutex();
        }
        public MyTraceContext(string component)
        {
            switch (component)
            {
                case "Server":
                    this.Component = LogComponent.Server;
                    break;

                case "Client":
                    this.Component = LogComponent.Client;
                    break;

                default:
                    throw new Exception();
            }
        }