public void Log <T1, T2, T3, T4>(LogLevel level, TMessageEnum msgId, T1 arg1, T2 arg2, T3 arg3, T4 arg4) where T1 : ILoggableValue where T2 : ILoggableValue where T3 : ILoggableValue where T4 : ILoggableValue { _tracer?.Trace(level, _name, LogEnum.GetMsg(msgId), arg1.Unwrap(), arg2.Unwrap(), arg3.Unwrap(), arg4.Unwrap()); var length = EntryHeader.Size + arg1.SizeOf() + arg2.SizeOf() + arg3.SizeOf() + arg4.SizeOf(); var header = new EntryHeader((ushort)length, _channelId, LogEnum.ToUInt16(msgId), level, 4); var span = GetSpan(length); var bytesWritten = header.WriteTo(span); bytesWritten += arg1.WriteTo(span.Slice(bytesWritten)); bytesWritten += arg2.WriteTo(span.Slice(bytesWritten)); bytesWritten += arg3.WriteTo(span.Slice(bytesWritten)); bytesWritten += arg4.WriteTo(span.Slice(bytesWritten)); if (bytesWritten != length) { throw new SerializationException("Failed to serialize log entry"); } _stream.Write(_buffer, 0, bytesWritten); }
public void Log(LogLevel level, TMessageEnum msgId) { _tracer?.Trace(level, _name, LogEnum.GetMsg(msgId)); var span = GetSpan(EntryHeader.Size); var header = new EntryHeader(EntryHeader.Size, _channelId, LogEnum.ToUInt16(msgId), level, 0); var bytesWritten = header.WriteTo(span); if (bytesWritten != EntryHeader.Size) { throw new SerializationException("Failed to serialize log entry"); } _stream.Write(_buffer, 0, bytesWritten); }