Ejemplo n.º 1
0
 public void Log(NHibernateLogLevel logLevel, NHibernateLogValues state, Exception exception)
 {
 }
Ejemplo n.º 2
0
        public void Log(NHibernateLogLevel logLevel, NHibernateLogValues state, Exception exception)
        {
            if (!IsEnabled(logLevel))
            {
                return;
            }

            switch (logLevel)
            {
            case NHibernateLogLevel.Debug:
            case NHibernateLogLevel.Trace:
                if (exception != null)
                {
                    _internalLogger.Debug(state, exception);
                }
                else if (state.Args?.Length > 0)
                {
                    _internalLogger.DebugFormat(state.Format, state.Args);
                }
                else
                {
                    _internalLogger.Debug(state);
                }
                break;

            case NHibernateLogLevel.Info:
                if (exception != null)
                {
                    _internalLogger.Info(state, exception);
                }
                else if (state.Args?.Length > 0)
                {
                    _internalLogger.InfoFormat(state.Format, state.Args);
                }
                else
                {
                    _internalLogger.Info(state);
                }
                break;

            case NHibernateLogLevel.Warn:
                if (exception != null)
                {
                    _internalLogger.Warn(state, exception);
                }
                else if (state.Args?.Length > 0)
                {
                    _internalLogger.WarnFormat(state.Format, state.Args);
                }
                else
                {
                    _internalLogger.Warn(state);
                }
                break;

            case NHibernateLogLevel.Error:
                if (exception != null)
                {
                    _internalLogger.Error(state, exception);
                }
                else if (state.Args?.Length > 0)
                {
                    _internalLogger.ErrorFormat(state.Format, state.Args);
                }
                else
                {
                    _internalLogger.Error(state);
                }
                break;

            case NHibernateLogLevel.Fatal:
                if (exception != null)
                {
                    _internalLogger.Fatal(state, exception);
                }
                else
                {
                    _internalLogger.Fatal(state);
                }
                break;

            case NHibernateLogLevel.None:
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(logLevel), logLevel, null);
            }
        }