Example #1
0
        public BodySet()
        {
            this.message = new LogMessage {
                Level = LogLevel.Fatal,
                Source = "test-source",
                Host = "web-server1",
                Text = "Something wild",
                Time = Time.MillisecondNow
            };

            this.jsonTemplate = "{\"host\":\"web-server1\",\"level\":3,\"source\":\"test-source\",\"text\":\"Something wild\",\"time\":[TIME]}";

            this.settings = new NameValueCollection();
            this.settings["progstr.log.apitoken"] = "DEMO";
            this.client = new TestClient(this.settings);
        }
Example #2
0
 public override void Execute(LogMessage message)
 {
     var request = CreateLogRequest(message);
     LastBody = request.Data;
 }
Example #3
0
 public virtual void Execute(LogMessage message)
 {
     var request = this.CreateLogRequest(message);
     request.Start();
 }
Example #4
0
        private byte[] EncodeData(LogMessage message)
        {
            var buffer = new MemoryStream();
            var serializer = new DataContractJsonSerializer(typeof(LogMessage));
            serializer.WriteObject(buffer, message);

            var data = buffer.ToArray();
            if (this.EnableCompression)
                data = this.Compress(data);

            return data;
        }
Example #5
0
        protected LogRequest CreateLogRequest(LogMessage message)
        {
            var webRequest = this.CreateWebRequest();
            this.ConfigureRequest(webRequest);

            var data = this.EncodeData(message);

            return new LogRequest(webRequest) { Data = data };
        }
Example #6
0
        public virtual void Send(LogMessage message)
        {
            Shutdown.StartRequest();

            Action asyncAction = () => {
                this.Execute(message);
            };
            asyncAction.BeginInvoke((result) => {}, null);
        }
Example #7
0
        private void LogWithLevel(LogLevel level, string text)
        {
            var message = new LogMessage {
                Source = this.source,
                Text = text,
                Level = level,
                Host = LogEnvironment.Host,
                Time = Time.MillisecondNow
            };

            this.Client.Send(message);
        }