Skip to content

Commit

Permalink
plug amqpnetlite logging system (ITrace) into NMS Tracer logging system
Browse files Browse the repository at this point in the history
  • Loading branch information
Havret committed Jul 16, 2019
1 parent 6312814 commit a8bd8f0
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions src/NMS.AMQP/Transport/TransportContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,49 @@ internal TransportContext()
connectionBuilder.SASL.Profile = Amqp.Sasl.SaslProfile.Anonymous;
}

static TransportContext()
{
//
// Set up tracing in AMQP. We capture all AMQP traces in the TraceListener below
// and map to NMS 'Tracer' logs as follows:
// AMQP Tracer
// Verbose Debug
// Frame Debug
// Information Info
// Output Info (should not happen)
// Warning Warn
// Error Error
//
Amqp.Trace.TraceLevel = Amqp.TraceLevel.Verbose | Amqp.TraceLevel.Frame;
Amqp.Trace.TraceListener = (level, format, args) =>
{
switch (level)
{
case Amqp.TraceLevel.Verbose:
case Amqp.TraceLevel.Frame:
Tracer.DebugFormat(format, args);
break;
case Amqp.TraceLevel.Information:
case Amqp.TraceLevel.Output:
//
// Applications should not access AmqpLite directly so there
// should be no 'Output' level logs.
Tracer.InfoFormat(format, args);
break;
case Amqp.TraceLevel.Warning:
Tracer.WarnFormat(format, args);
break;
case Amqp.TraceLevel.Error:
Tracer.ErrorFormat(format, args);
break;
default:
Tracer.InfoFormat("Unknown AMQP LogLevel: {}", level);
Tracer.InfoFormat(format, args);
break;
}
};
}

#region Transport Options

public int ReceiveBufferSize { get => this.connectionBuilder.TCP.ReceiveBufferSize; set => this.connectionBuilder.TCP.ReceiveBufferSize = value; }
Expand Down

0 comments on commit a8bd8f0

Please sign in to comment.