public DefaultNonCachedLessCssLoaderFactory(
            ITextFileLoader contentLoader,
            SourceMappingMarkerInjectionOptions sourceMappingMarkerInjection,
            ErrorBehaviourOptions errorBehaviour,
            ILogEvents logger)
        {
            if (contentLoader == null)
            {
                throw new ArgumentNullException("contentLoader");
            }
            if (!Enum.IsDefined(typeof(SourceMappingMarkerInjectionOptions), sourceMappingMarkerInjection))
            {
                throw new ArgumentOutOfRangeException("sourceMappingMarkerInjection");
            }
            if (!Enum.IsDefined(typeof(ErrorBehaviourOptions), errorBehaviour))
            {
                throw new ArgumentOutOfRangeException("lineNumberInjectionBehaviour");
            }
            if (logger == null)
            {
                throw new ArgumentNullException("logger");
            }

            _contentLoader = contentLoader;
            _sourceMappingMarkerInjection = sourceMappingMarkerInjection;
            _errorBehaviour = errorBehaviour;
            _logger         = logger;
        }
Esempio n. 2
0
        public DotLessCssCssLoader(
            ITextFileLoader contentLoader,
            InsertedMarkerRetriever markerIdRetriever,
            string optionalTagNameToRemove,
            ErrorBehaviourOptions reportedErrorBehaviour,
            ILogEvents logger)
        {
            if (contentLoader == null)
            {
                throw new ArgumentNullException("contentLoader");
            }
            if (markerIdRetriever == null)
            {
                throw new ArgumentNullException("markerIdRetriever");
            }
            if (!Enum.IsDefined(typeof(ErrorBehaviourOptions), reportedErrorBehaviour))
            {
                throw new ArgumentOutOfRangeException("reportedErrorBehaviour");
            }
            if (logger == null)
            {
                throw new ArgumentNullException("logger");
            }

            _contentLoader           = contentLoader;
            _markerIdRetriever       = markerIdRetriever;
            _optionalTagNameToRemove = optionalTagNameToRemove;
            _reportedErrorBehaviour  = reportedErrorBehaviour;
            _logger = logger;
        }
        public SameFolderImportFlatteningCssLoader(
            ITextFileLoader contentLoader,
            ContentLoaderCommentRemovalBehaviourOptions contentLoaderCommentRemovalBehaviour,
            ErrorBehaviourOptions circularReferenceImportBehaviour,
            ErrorBehaviourOptions unsupportedImportBehaviour,
            ILogEvents logger)
        {
            if (contentLoader == null)
            {
                throw new ArgumentNullException("contentLoader");
            }
            if (!Enum.IsDefined(typeof(ContentLoaderCommentRemovalBehaviourOptions), contentLoaderCommentRemovalBehaviour))
            {
                throw new ArgumentOutOfRangeException("contentLoaderCommentRemovalBehaviour");
            }
            if (!Enum.IsDefined(typeof(ErrorBehaviourOptions), circularReferenceImportBehaviour))
            {
                throw new ArgumentOutOfRangeException("circularReferenceImportBehaviour");
            }
            if (!Enum.IsDefined(typeof(ErrorBehaviourOptions), unsupportedImportBehaviour))
            {
                throw new ArgumentOutOfRangeException("unsupportedImportBehaviour");
            }
            if (logger == null)
            {
                throw new ArgumentNullException("logger");
            }

            _contentLoader = contentLoader;
            _contentLoaderCommentRemovalBehaviour = contentLoaderCommentRemovalBehaviour;
            _circularReferenceImportBehaviour     = circularReferenceImportBehaviour;
            _unsupportedImportBehaviour           = unsupportedImportBehaviour;
            _logger = logger;
        }
Esempio n. 4
0
        public FilteredLogger(ILogEvents logger, IEnumerable <LogLevel> allowedLogLevels, ErrorBehaviourOptions individualLogEntryErrorBehaviour)
        {
            if (logger == null)
            {
                throw new ArgumentNullException(nameof(logger));
            }
            if (allowedLogLevels == null)
            {
                throw new ArgumentNullException(nameof(allowedLogLevels));
            }
            if ((individualLogEntryErrorBehaviour != ErrorBehaviourOptions.Ignore) && (individualLogEntryErrorBehaviour != ErrorBehaviourOptions.ThrowException))
            {
                // Note: Explicitly check for all valid values rather than using Enum.IsDefined since IsDefined uses reflection and logging should be as cheap as possible
                // (so reflection is best avoided)
                throw new ArgumentOutOfRangeException(nameof(individualLogEntryErrorBehaviour));
            }

            IndividualLogEntryErrorBehaviour = individualLogEntryErrorBehaviour;

            _logger          = logger;
            AllowedLogLevels = allowedLogLevels.ToList().AsReadOnly();
            foreach (var allowedLogLevel in AllowedLogLevels)
            {
                if ((allowedLogLevel != LogLevel.Debug) && (allowedLogLevel != LogLevel.Info) && (allowedLogLevel != LogLevel.Warning) && (allowedLogLevel != LogLevel.Error))
                {
                    throw new ArgumentException("Invalid LogLevel value specified");
                }
            }
        }
 public DefaultNonCachedLessCssLoaderFactory(
     IRelativePathMapper pathMapper,
     SourceMappingMarkerInjectionOptions sourceMappingMarkerInjection,
     ErrorBehaviourOptions errorBehaviour,
     ILogEvents logger)
     : this(new SimpleTextFileContentLoader(pathMapper), sourceMappingMarkerInjection, errorBehaviour, logger)
 {
 }
Esempio n. 6
0
 public FileLogger(
     FileInfo file,
     Func <LogEventDetails, string> messageFormatter,
     ErrorBehaviourOptions individualLogEntryErrorBehaviour,
     bool tryToCreateFolderIfRequired,
     object optionalSyncLock)
     : base(messageFormatter, GetOutputWriter(file, null, tryToCreateFolderIfRequired, optionalSyncLock), individualLogEntryErrorBehaviour)
 {
 }
Esempio n. 7
0
            public DotLessCssPassThroughLogger(ILogEvents logger, ErrorBehaviourOptions reportedErrorBehaviour)
            {
                if (logger == null)
                {
                    throw new ArgumentNullException("logger");
                }
                if (!Enum.IsDefined(typeof(ErrorBehaviourOptions), reportedErrorBehaviour))
                {
                    throw new ArgumentOutOfRangeException("reportedErrorBehaviour");
                }

                _logger = logger;
                _reportedErrorBehaviour = reportedErrorBehaviour;
            }
Esempio n. 8
0
        public ThrottlingLogger(
            ILogEvents logger,
            TimeSpan mimimumFrequency,
            int maximumNumberOfBufferedItems,
            MessageEvaluationBehaviourOptions messageEvaluationBehaviour,
            ErrorBehaviourOptions individualLogEntryErrorBehaviour)
        {
            if (logger == null)
            {
                throw new ArgumentNullException(nameof(logger));
            }
            if (mimimumFrequency.Ticks <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(mimimumFrequency), "must be a positive duration");
            }
            if (maximumNumberOfBufferedItems <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(maximumNumberOfBufferedItems), "must be a positive value");
            }
            if ((messageEvaluationBehaviour != MessageEvaluationBehaviourOptions.EvaluateWhenLogged) && (messageEvaluationBehaviour != MessageEvaluationBehaviourOptions.EvaluateWhenQueued))
            {
                // Note: Explicitly check for all valid values rather than using Enum.IsDefined since IsDefined uses reflection and logging should be as cheap as possible
                // (so reflection is best avoided)
                throw new ArgumentOutOfRangeException(nameof(messageEvaluationBehaviour));
            }
            if ((individualLogEntryErrorBehaviour != ErrorBehaviourOptions.Ignore) && (individualLogEntryErrorBehaviour != ErrorBehaviourOptions.ThrowException))
            {
                // Note: Explicitly check for all valid values rather than using Enum.IsDefined since IsDefined uses reflection and logging should be as cheap as possible
                // (so reflection is best avoided)
                throw new ArgumentOutOfRangeException(nameof(individualLogEntryErrorBehaviour));
            }

            MaximumNumberOfBufferedItems     = maximumNumberOfBufferedItems;
            MinimumFrequency                 = mimimumFrequency;
            MessageEvaluationBehaviour       = messageEvaluationBehaviour;
            IndividualLogEntryErrorBehaviour = individualLogEntryErrorBehaviour;

            _logger   = logger;
            _messages = new ConcurrentQueue <LogEventDetails>();
            _timer    = new PauseableTimer(
                mimimumFrequency,
                FlushQueueIfNotAlreadyDoingSo
                );
            _lastFlushedAt            = null;
            _flushInProgressIndicator = 0;
        }
Esempio n. 9
0
        public CombinedLogger(IEnumerable <ILogEvents> loggers, ErrorBehaviourOptions individualLoggerErrorBehaviour)
        {
            if (loggers == null)
            {
                throw new ArgumentNullException(nameof(loggers));
            }
            if ((individualLoggerErrorBehaviour != ErrorBehaviourOptions.Ignore) && (individualLoggerErrorBehaviour != ErrorBehaviourOptions.ThrowException))
            {
                // Note: Explicitly check for all valid values rather than using Enum.IsDefined since IsDefined uses reflection and logging should be as cheap as possible
                // (so reflection is best avoided)
                throw new ArgumentOutOfRangeException(nameof(individualLoggerErrorBehaviour));
            }

            Loggers = loggers.ToList().AsReadOnly();
            if (Loggers.Any(logger => logger == null))
            {
                throw new ArgumentException("Null reference encountered in loggers set");
            }
            IndividualLoggerErrorBehaviour = individualLoggerErrorBehaviour;
        }
Esempio n. 10
0
        protected TextLogger(Func <LogEventDetails, string> messageFormatter, Action <string> outputWriter, ErrorBehaviourOptions individualLogEntryErrorBehaviour)
        {
            if (messageFormatter == null)
            {
                throw new ArgumentNullException(nameof(messageFormatter));
            }
            if (outputWriter == null)
            {
                throw new ArgumentNullException(nameof(outputWriter));
            }
            if ((individualLogEntryErrorBehaviour != ErrorBehaviourOptions.Ignore) && (individualLogEntryErrorBehaviour != ErrorBehaviourOptions.ThrowException))
            {
                // Note: Explicitly check for all valid values rather than using Enum.IsDefined since IsDefined uses reflection and logging should be as cheap as possible
                // (so reflection is best avoided)
                throw new ArgumentOutOfRangeException(nameof(individualLogEntryErrorBehaviour));
            }

            IndividualLogEntryErrorBehaviour = individualLogEntryErrorBehaviour;
            _messageFormatter = messageFormatter;
            _outputWriter     = outputWriter;
        }
        public DiskCachingTextFileLoader(
            ITextFileLoader contentLoader,
            CacheFileLocationRetriever cacheFileLocationRetriever,
            ILastModifiedDateRetriever lastModifiedDateRetriever,
            InvalidContentBehaviourOptions invalidContentBehaviour,
            ErrorBehaviourOptions errorBehaviour,
            ILogEvents logger)
        {
            if (contentLoader == null)
            {
                throw new ArgumentNullException("contentLoader");
            }
            if (cacheFileLocationRetriever == null)
            {
                throw new ArgumentNullException("cacheFileLocationRetriever");
            }
            if (lastModifiedDateRetriever == null)
            {
                throw new ArgumentNullException("lastModifiedDateRetriever");
            }
            if (!Enum.IsDefined(typeof(InvalidContentBehaviourOptions), invalidContentBehaviour))
            {
                throw new ArgumentOutOfRangeException("invalidContentBehaviour");
            }
            if (!Enum.IsDefined(typeof(ErrorBehaviourOptions), errorBehaviour))
            {
                throw new ArgumentOutOfRangeException("errorBehaviour");
            }
            if (logger == null)
            {
                throw new ArgumentNullException("logger");
            }

            _contentLoader = contentLoader;
            _cacheFileLocationRetriever = cacheFileLocationRetriever;
            _lastModifiedDateRetriever  = lastModifiedDateRetriever;
            _invalidContentBehaviour    = invalidContentBehaviour;
            _errorBehaviour             = errorBehaviour;
            _logger = logger;
        }
Esempio n. 12
0
        public ErrorWithBackTrackLogger(
            ILogEvents logger,
            int maximumNumberOfHistoricalMessagesToMaintain,
            int maximumNumberOfHistoricalMessagesToIncludeWithAnErrorEntry,
            HistoryLoggingBehaviourOptions historyLoggingBehaviour,
            ErrorBehaviourOptions individualLogEntryErrorBehaviour)
        {
            if (logger == null)
            {
                throw new ArgumentNullException(nameof(logger));
            }
            if (maximumNumberOfHistoricalMessagesToMaintain <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(maximumNumberOfHistoricalMessagesToMaintain), "must be greater than zero");
            }
            if (maximumNumberOfHistoricalMessagesToIncludeWithAnErrorEntry <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(maximumNumberOfHistoricalMessagesToIncludeWithAnErrorEntry), "must be greater than zero");
            }
            if ((historyLoggingBehaviour != HistoryLoggingBehaviourOptions.IncludeAllPrecedingMessages) && (historyLoggingBehaviour != HistoryLoggingBehaviourOptions.IncludePrecedingMessagesFromTheSameThreadOnly))
            {
                // Note: Explicitly check for all valid values rather than using Enum.IsDefined since IsDefined uses reflection and logging should be as cheap as possible
                // (so reflection is best avoided)
                throw new ArgumentOutOfRangeException(nameof(historyLoggingBehaviour));
            }
            if ((individualLogEntryErrorBehaviour != ErrorBehaviourOptions.Ignore) && (individualLogEntryErrorBehaviour != ErrorBehaviourOptions.ThrowException))
            {
                // Note: Explicitly check for all valid values rather than using Enum.IsDefined since IsDefined uses reflection and logging should be as cheap as possible
                // (so reflection is best avoided)
                throw new ArgumentOutOfRangeException(nameof(individualLogEntryErrorBehaviour));
            }

            MaximumNumberOfHistoricalMessagesToMaintain = maximumNumberOfHistoricalMessagesToMaintain;
            MaximumNumberOfHistoricalMessagesToIncludeWithAnErrorEntry = maximumNumberOfHistoricalMessagesToIncludeWithAnErrorEntry;
            HistoryLoggingBehaviour          = historyLoggingBehaviour;
            IndividualLogEntryErrorBehaviour = individualLogEntryErrorBehaviour;

            _logger   = logger;
            _messages = new Queue <LogEventDetails>(maximumNumberOfHistoricalMessagesToMaintain);
        }
Esempio n. 13
0
 public ConsoleLogger(Func <LogEventDetails, string> messageFormatter, ErrorBehaviourOptions individualLogEntryErrorBehaviour)
     : base(messageFormatter, content => Console.WriteLine(content), individualLogEntryErrorBehaviour)
 {
 }
Esempio n. 14
0
 /// <summary>
 /// This constructor is used if you just want a straight LESS compilation-and-minification without any handling of source mapping marker ids or scope-restricting
 /// selector removals
 /// </summary>
 public DotLessCssCssLoader(ITextFileLoader contentLoader, ErrorBehaviourOptions reportedErrorBehaviour, ILogEvents logger)
     : this(contentLoader, () => new string[0], null, reportedErrorBehaviour, logger)
 {
 }