GSF.Diagnostics.LogEventPublisher.Publish C# (CSharp) Method

Publish() public method

Raises a log message with the provided data.
public Publish ( MessageFlags flags, string message = null, string details = null, Exception exception = null ) : void
flags MessageFlags additional flags to set to this log
message string
details string A long text field with the details of the message.
exception System.Exception An exception object if one is provided.
return void
        public void Publish(MessageFlags flags, string message = null, string details = null, Exception exception = null)
        {
            m_internalPublisher.Publish(m_internalPublisher.DefaultAttributes + flags, message, details, exception, m_publisher.InitialStackMessages, m_publisher.InitialStackTrace);
        }
    }

Same methods

LogEventPublisher::Publish ( string message = null, string details = null, Exception exception = null ) : void

Usage Example

コード例 #1
0
        /// <summary>
        /// Raises a log message with the provided data.
        /// </summary>
        /// <param name="overriddenAttributes">attributes to use with this message</param>
        /// <param name="message"></param>
        /// <param name="details">A long text field with the details of the message.</param>
        /// <param name="exception">An exception object if one is provided.</param>
        /// <param name="initialStackMessage"></param>
        /// <param name="initialStackTrace"></param>
        public void Publish(LogMessageAttributes?overriddenAttributes, string message, string details, Exception exception, LogStackMessages initialStackMessage, LogStackTrace initialStackTrace)
        {
            if (Logger.ShouldSuppressLogMessages)
            {
                return;
            }

            LogMessageAttributes attributes = overriddenAttributes ?? m_attributes;

            if (!m_publisher.HasSubscribers(attributes))
            {
                return;
            }

            if (message == null)
            {
                message = string.Empty;
            }
            if (details == null)
            {
                details = string.Empty;
            }

            var suppressionFlags = m_supressionEngine.IncrementPublishCount();

            if (suppressionFlags != MessageSuppression.None)
            {
                m_messagesSuppressed++;

                if (ShouldRaiseMessageSupressionNotifications && m_suppressionMessageNextPublishTime <= ShortTime.Now)
                {
                    m_suppressionMessageNextPublishTime = ShortTime.Now.AddSeconds(10);
                    MessageSuppressionIndication.Publish($"Message Suppression Is Occurring To: '{ m_owner.TypeData.TypeName }' {m_messagesSuppressed.ToString()} total messages have been suppressed.", m_owner.ToString());
                }

                attributes += suppressionFlags;
                if (!m_publisher.HasSubscribers(attributes))
                {
                    return;
                }
            }

            LogStackMessages currentStackMessages = Logger.GetStackMessages();
            LogStackTrace    currentStackTrace    = LogStackTrace.Empty;

            if (m_stackTraceDepth > 0)
            {
                currentStackTrace = new LogStackTrace(true, 2, m_stackTraceDepth);
            }
            else if (exception != null || attributes.Level >= MessageLevel.Error)
            {
                currentStackTrace = new LogStackTrace(true, 2, 10);
            }

            var logMessage = new LogMessage(m_owner, initialStackMessage, initialStackTrace, currentStackMessages, currentStackTrace, attributes, message, details, exception);

            m_logger.OnNewMessage(logMessage, m_publisher);
        }
All Usage Examples Of GSF.Diagnostics.LogEventPublisher::Publish