Exemplo n.º 1
0
        private void CreateLogFiles(IRockLogger logger, int maxFilesizeInMB, int numberOfFiles)
        {
            var maxByteCount         = maxFilesizeInMB * 1024 * 1024 * numberOfFiles;
            var currentByteCount     = 0;
            var logHeaderInformation = "0000-00-00 00:00:00.000 -00:00 [INF] OTHER";

            while (currentByteCount < maxByteCount)
            {
                var expectedLogMessage = $"Test - {Guid.NewGuid()}";
                logger.Information(expectedLogMessage);

                currentByteCount += Encoding.ASCII.GetByteCount($"{logHeaderInformation} {expectedLogMessage}");
            }
            TestContext.WriteLine("CreateLogFiles wrote {0} bytes of logs to {1}.", currentByteCount, logger.LogConfiguration.LogPath);
        }
Exemplo n.º 2
0
        private List <string> CreateLogFiles(IRockLogger logger)
        {
            var maxByteCount     = logger.LogConfiguration.MaxFileSize * 1024 * 1024 * (logger.LogConfiguration.NumberOfLogFiles - 1);
            var currentByteCount = 0;
            var logRecordSize    = Encoding.ASCII.GetByteCount("{\"@t\":\"0000-00-00T00:00:00.0000000Z\",\"@mt\":\"{domain} Test - 00000000-0000-0000-0000-000000000000\",\"domain\":\"OTHER\"}");
            var expectedLogs     = new List <string>();

            while (currentByteCount < maxByteCount)
            {
                var guid = Guid.NewGuid();
                var expectedLogMessage = $"Test - {guid}";
                logger.Information(RockLogDomains.Other, expectedLogMessage);
                expectedLogs.Add(guid.ToString());
                currentByteCount += logRecordSize;
            }
            return(expectedLogs);
        }