public LogsListener(TimberWinR.Parser.LogParameters arguments, CancellationToken cancelToken)
            : base(cancelToken, "Win32-FileLog")
        {
            Stop = false;

            EnsureRollingCaught();

             _codecArguments = arguments.CodecArguments;

            _codecArguments = arguments.CodecArguments;
            if (_codecArguments != null && _codecArguments.Type == CodecArguments.CodecType.multiline)
                _codec = new Multiline(_codecArguments);

            if (!string.IsNullOrEmpty(arguments.Type))
                SetTypeName(arguments.Type);

            _receivedMessages = 0;
            _arguments = arguments;
            _pollingIntervalInSeconds = arguments.Interval;

            IsWildcardFilePattern = arguments.Location.Contains('*');

            foreach (string srcFile in _arguments.Location.Split(','))
            {
                string file = srcFile.Trim();
                string dir = Path.GetDirectoryName(file);
                if (string.IsNullOrEmpty(dir))
                    dir = Environment.CurrentDirectory;
                string fileSpec = Path.Combine(dir, file);

                Task.Factory.StartNew(() => FileWatcher(fileSpec));
            }
        }
Exemple #2
0
        public LogsListener(TimberWinR.Parser.LogParameters arguments, CancellationToken cancelToken)
            : base(cancelToken, "Win32-FileLog")
        {
            Stop = false;

            EnsureRollingCaught();

            _codecArguments = arguments.CodecArguments;

            _codecArguments = arguments.CodecArguments;
            if (_codecArguments != null && _codecArguments.Type == CodecArguments.CodecType.multiline)
            {
                _codec = new Multiline(_codecArguments);
            }

            if (!string.IsNullOrEmpty(arguments.Type))
            {
                SetTypeName(arguments.Type);
            }

            _receivedMessages         = 0;
            _arguments                = arguments;
            _pollingIntervalInSeconds = arguments.Interval;

            IsWildcardFilePattern = arguments.Location.Contains('*');

            foreach (string srcFile in _arguments.Location.Split(','))
            {
                string file = srcFile.Trim();
                string dir  = Path.GetDirectoryName(file);
                if (string.IsNullOrEmpty(dir))
                {
                    dir = Environment.CurrentDirectory;
                }
                string fileSpec = Path.Combine(dir, file);

                Task.Factory.StartNew(() => FileWatcher(fileSpec));
            }
        }