Beispiel #1
0
        public static bool LogMessage(string message, LogLevel logLevel)
        {
            var messageLogged = false;

            if (_logLevelsAllowed.Count <= 0)
            {
                throw new IndexOutOfRangeException("Log levels");
            }

            if (_logTypesAllowed.Count <= 0)
            {
                throw new IndexOutOfRangeException("Log types");
            }

            if (!_logLevelsAllowed.Contains(logLevel))
            {
                return(messageLogged);
            }

            if (_logTypesAllowed.Contains(LogType.TextFile))
            {
                _textFileJobLogger.LogMessage(message, logLevel);
                messageLogged = true;
            }

            if (_logTypesAllowed.Contains(LogType.Database))
            {
                _databaseJobLogger.LogMessage(message, logLevel);
                messageLogged = true;
            }

            if (_logTypesAllowed.Contains(LogType.Console))
            {
                _consoleJobLogger.LogMessage(message, logLevel);
                messageLogged = true;
            }

            return(messageLogged);
        }