Esempio n. 1
0
        private static void Message(LogMessageType type, string message)
        {
            LoadSettings();

            if ((LoggingLevel & type) == 0)
            {
                return;
            }
            System.Diagnostics.Debug.WriteLine(string.Format("{0}  {1}", type, message));
            OnTraceMessage?.BeginInvoke(type, message, null, null);

            if (!LoggingEnabled)
            {
                return;
            }
            string msg = FormatMessage(type, message);

            WriteMessageToLog(msg);
        }
Esempio n. 2
0
        private static void SetupAmqpLogging()
        {
            if (!settings.AmqpTraceEnabled)
            {
                Amqp.Trace.TraceLevel    = 0;
                Amqp.Trace.TraceListener = null;
                return;
            }

            Amqp.TraceLevel level = 0;
            if ((settings.LoggingLevel & LogMessageType.Debug) != 0)
            {
                level |= (Amqp.TraceLevel.Frame | Amqp.TraceLevel.Verbose | Amqp.TraceLevel.Output);
            }
            if ((settings.LoggingLevel & LogMessageType.Warn) != 0)
            {
                level |= Amqp.TraceLevel.Warning;
            }
            if ((settings.LoggingLevel & LogMessageType.Error) != 0)
            {
                level |= Amqp.TraceLevel.Error;
            }
            if ((settings.LoggingLevel & LogMessageType.Info) != 0)
            {
                level |= Amqp.TraceLevel.Information;
            }

            Amqp.Trace.TraceLevel = level;
            if (level != 0)
            {
                Amqp.Trace.TraceListener = (l, f, a) =>
                {
                    string msg = string.Format(f, a);
                    OnTraceMessage?.BeginInvoke(LogMessageType.Debug, msg, null, null);
                    System.Diagnostics.Debug.WriteLine(msg);
                    WriteMessageToLog(msg);
                }
            }
            ;
        }