예제 #1
0
        public void TestSequenceOn()
        {
            var naming = new FileNamingParameters()
            {
                IncludeLevel     = false,
                IncludeLogger    = false,
                IncludeSequence  = true,
                IncludeSession   = false,
                IncludeTimestamp = FileTimestampMode.None
            };

            // ok...
            var info = GetLogEventInfo();

            // check...
            var filename = naming.GetFilename(new LogWriteContext(), info);

            Assert.Equal(string.Format("Log - {0}.log", info.SequenceID), filename);
        }
예제 #2
0
        public void TestEverythingOff()
        {
            var naming = new FileNamingParameters()
            {
                IncludeLevel     = false,
                IncludeLogger    = false,
                IncludeSequence  = false,
                IncludeSession   = false,
                IncludeTimestamp = FileTimestampMode.None
            };

            // ok...
            var info = GetLogEventInfo();

            // check...
            var filename = naming.GetFilename(new LogWriteContext(), info);

            Assert.Equal("Log.log", filename);
        }
예제 #3
0
        public void TestTimestampBoth()
        {
            var naming = new FileNamingParameters()
            {
                IncludeLevel     = false,
                IncludeLogger    = false,
                IncludeSequence  = false,
                IncludeSession   = false,
                IncludeTimestamp = FileTimestampMode.DateTime
            };

            // ok...
            var info = GetLogEventInfo();

            // check...
            var filename = naming.GetFilename(new LogWriteContext(), info);

            Assert.Equal(string.Format("Log - {0}.log", LogManagerBase.GetDateTime().ToString("yyyyMMdd HHmmss")), filename);
        }
예제 #4
0
        public void TestEverythingOn()
        {
            var naming = new FileNamingParameters()
            {
                IncludeLevel     = true,
                IncludeLogger    = true,
                IncludeSequence  = true,
                IncludeSession   = true,
                IncludeTimestamp = FileTimestampMode.DateTime
            };

            // ok...
            var info = GetLogEventInfo();

            // check...
            var context  = new LogWriteContext();
            var filename = naming.GetFilename(context, info);

            Assert.Equal($"Log - INFO - foobar - {LogManager.GetDateTime() .ToString("yyyyMMdd HHmmss")} - {context.Environment.SessionId} - {info.SequenceID}.log", filename);
        }
예제 #5
0
        private async Task ZipFolderContents(StorageFolder sourceFolder, ZipArchive archive, string baseDirPath)
        {
            var files = await sourceFolder.GetFilesAsync();

            var pattern = FileNamingParameters.GetRegex();

            foreach (var file in files)
            {
                if (pattern.Match(file.Name).Success)
                {
                    var readmeEntry = archive.CreateEntry(file.Name);

                    var buffer = await ReadStorageFileToByteBuffer(file);

                    var entryStream = readmeEntry.Open();
                    await entryStream.WriteAsync(buffer, 0, buffer.Length);

                    await entryStream.FlushAsync();

                    entryStream.Dispose();
                }
            }
        }
예제 #6
0
        public void TestRegexEverythingOn()
        {
            var naming = new FileNamingParameters()
            {
                IncludeLevel     = true,
                IncludeLogger    = true,
                IncludeSequence  = true,
                IncludeSession   = true,
                IncludeTimestamp = FileTimestampMode.DateTime
            };

            // get...
            var regex = naming.GetRegex();

            // create...
            var info = GetLogEventInfo();

            // check...
            var context  = new LogWriteContext();
            var filename = naming.GetFilename(context, info);

            // check...
            Assert.True(regex.Match(filename).Success);
        }