コード例 #1
0
        public void EnumerationIsInOrder()
        {
            using (var temp = TempFolder.ForCaller())
                using (var buffer = new LogBuffer(temp.AllocateFilename("mdb"), DefaultBufferSize))
                {
                    byte[] a1 = Some.Bytes(140), a2 = Some.Bytes(140), a3 = Some.Bytes(140);
                    buffer.Enqueue(new[] { a1, a2, a3 });

                    var contents = new List <byte[]>();
                    buffer.Enumerate((k, v) =>
                    {
                        contents.Add(v);
                    });

                    Assert.Equal(3, contents.Count);
                    Assert.Equal(new[] { a1, a2, a3 }, contents);
                }
        }
コード例 #2
0
        protected override int Run(TextWriter cout)
        {
            try
            {
                var config = SeqForwarderConfig.Read(_storagePath.ConfigFilePath);
                var buffer = new LogBuffer(_storagePath.BufferPath, config.Storage.BufferSizeBytes);
                buffer.Enumerate((k, v) =>
                {
                    var s = Encoding.UTF8.GetString(v);
                    Console.WriteLine(s);
                });
                return(0);
            }
            catch (Exception ex)
            {
                var logger = new LoggerConfiguration().WriteTo.LiterateConsole().CreateLogger();

                logger.Fatal(ex, "Could not dump events");
                return(1);
            }
        }