public void SendMessage()
        {
            var server = new DummyServer();
            var task   = server.Run(24224);
            var date   = MessagePackConvert.ToDateTime(1360370224238);

            using (var sender = FluentSender.CreateSync("app").Result)
            {
                sender.EmitWithTimeAsync("hoge", date, new { message = "hoge" });
            }
            var ret = task.Result;

            Utils.Unpack(ret).Is(@"[ ""app.hoge"", [ [ 1360370224.238, { ""message"" : ""hoge"" } ] ] ]");
        }
Esempio n. 2
0
        public FluentLoggerFactoryAdapter(NameValueCollection properties)
            : base(properties)
        {
            string tag      = (string)properties.ParseValue("tag") ?? "Fluent";
            string hostname = (string)properties.ParseValue("hostname") ?? "localhost";
            int    port     = properties.ParseValueOrDefault("port", 24224);
            int    bufmax   = properties.ParseValueOrDefault("bufmax", 1024 * 1024);
            int    timeout  = properties.ParseValueOrDefault("timeout", 3000);
            bool   verbose  = properties.ParseValueOrDefault("verbose", false);

            _sender = FluentSender.CreateSync(tag, hostname, port, bufmax, timeout, verbose).Result;

            _queue        = new BlockingCollection <Tuple <string, object> >(new ConcurrentQueue <Tuple <string, object> >());
            _cancellation = new CancellationTokenSource();


            Task.Factory.StartNew(WriteLog, _cancellation);
        }