예제 #1
0
        protected override void OnLog(ILogMessage message)
        {
            var serializableMessage = message as SerializableLogMessage;

            if (serializableMessage == null)
            {
                var assetMessage = message as AssetLogMessage;
                if (assetMessage != null)
                {
                    assetMessage.Module = mainLogger.Module;
                    serializableMessage = new AssetSerializableLogMessage(assetMessage);
                }
                else
                {
                    var logMessage = message as LogMessage;
                    serializableMessage = logMessage != null ? new SerializableLogMessage(logMessage) : null;
                }
            }

            if (serializableMessage == null)
            {
                throw new ArgumentException(@"Unable to process the given log message.", "message");
            }

            foreach (var remoteLog in remoteLogs)
            {
                try
                {
                    remoteLog.ForwardSerializableLog(serializableMessage);
                }
                // ReSharper disable EmptyGeneralCatchClause
                catch { }
                // ReSharper restore EmptyGeneralCatchClause
            }
        }
예제 #2
0
        protected override void OnLog(ILogMessage message)
        {
            var serializableMessage = message as SerializableLogMessage;
            if (serializableMessage == null)
            {
                var assetMessage = message as AssetLogMessage;
                if (assetMessage != null)
                {
                    assetMessage.Module = mainLogger.Module;
                    serializableMessage = new AssetSerializableLogMessage(assetMessage);
                }
                else
                {
                    var logMessage = message as LogMessage;
                    serializableMessage = logMessage != null ? new SerializableLogMessage(logMessage) : null;
                }
            }

            if (serializableMessage == null)
            {
                throw new ArgumentException(@"Unable to process the given log message.", "message");
            }

            foreach (var remoteLog in remoteLogs)
            {
                try
                {
                    remoteLog.ForwardSerializableLog(serializableMessage);
                }
                // ReSharper disable EmptyGeneralCatchClause
                catch { }
                // ReSharper restore EmptyGeneralCatchClause
            }
        }
예제 #3
0
        protected override void OnLog(ILogMessage message)
        {
            if (!activeRemoteLogs)
            {
                return;
            }

            var serializableMessage = message as SerializableLogMessage;

            if (serializableMessage == null)
            {
                var assetMessage = message as AssetLogMessage;
                if (assetMessage != null)
                {
                    assetMessage.Module = mainLogger.Module;
                    serializableMessage = new AssetSerializableLogMessage(assetMessage);
                }
                else
                {
                    var logMessage = message as LogMessage;
                    serializableMessage = logMessage != null ? new SerializableLogMessage(logMessage) : null;
                }
            }

            if (serializableMessage == null)
            {
                throw new ArgumentException(@"Unable to process the given log message.", "message");
            }

            for (int i = 0; i < remoteLogs.Count; i++)
            {
                var remoteLog = remoteLogs[i];
                try
                {
                    remoteLog?.ForwardSerializableLog(serializableMessage);
                }
                // ReSharper disable EmptyGeneralCatchClause
                catch
                {
                    // Communication failed, let's null it out so that we don't try again
                    remoteLogs[i] = null;
                    TryCloseChannel(remoteLog);

                    // Check if we still need to log anything
                    var newActiveRemoteLogs = false;
                    for (int j = 0; j < remoteLogs.Count; j++)
                    {
                        if (remoteLogs[j] != null)
                        {
                            newActiveRemoteLogs = true;
                            break;
                        }
                    }

                    activeRemoteLogs = newActiveRemoteLogs;
                }
                // ReSharper restore EmptyGeneralCatchClause
            }
        }
        protected override void OnLog(ILogMessage message)
        {
            if (!activeRemoteLogs)
                return;

            var serializableMessage = message as SerializableLogMessage;
            if (serializableMessage == null)
            {
                var assetMessage = message as AssetLogMessage;
                if (assetMessage != null)
                {
                    assetMessage.Module = mainLogger.Module;
                    serializableMessage = new AssetSerializableLogMessage(assetMessage);
                }
                else
                {
                    var logMessage = message as LogMessage;
                    serializableMessage = logMessage != null ? new SerializableLogMessage(logMessage) : null;
                }
            }

            if (serializableMessage == null)
            {
                throw new ArgumentException(@"Unable to process the given log message.", "message");
            }

            for (int i = 0; i < remoteLogs.Count; i++)
            {
                var remoteLog = remoteLogs[i];
                try
                {
                    remoteLog?.ForwardSerializableLog(serializableMessage);
                }
                    // ReSharper disable EmptyGeneralCatchClause
                catch
                {
                    // Communication failed, let's null it out so that we don't try again
                    remoteLogs[i] = null;
                    TryCloseChannel(remoteLog);

                    // Check if we still need to log anything
                    var newActiveRemoteLogs = false;
                    for (int j = 0; j < remoteLogs.Count; j++)
                    {
                        if (remoteLogs[j] != null)
                        {
                            newActiveRemoteLogs = true;
                            break;
                        }
                    }

                    activeRemoteLogs = newActiveRemoteLogs;
                }
                // ReSharper restore EmptyGeneralCatchClause
            }
        }