/// <summary>
 /// Stops the log stream.
 /// </summary>
 public void StopLogStream()
 {
     if (this.webSocket != null)
     {
         this.webSocket.Close();
         this.webSocket.Dispose();
         this.webSocket = null;
     }
 }
Beispiel #2
0
        /// <summary>
        /// Starts streaming logs from Logyard for the specified app, without tailing.
        /// </summary>
        /// <param name="appGuid">The Cloud Foundry app unique identifier.</param>
        /// <param name="recentEntriesCount">The last number of log entries that will be returned to the stream. The -1 value will use the default value configured on the server.</param>
        /// <param name="tail">If set to <c>true</c> the application log files will be tailed.</param>
        /// <exception cref="System.ArgumentNullException">appGuid</exception>
        public void StartLogStream(string appGuid, int recentEntriesCount, bool tail)
        {
            if (appGuid == null)
            {
                throw new ArgumentNullException("appGuid");
            }

            if (recentEntriesCount < -1)
            {
                throw new ArgumentOutOfRangeException("recentEntriesCount", "Number of entries value must bust be >= -1.");
            }

            if (this.webSocket != null)
            {
                throw new InvalidOperationException("The log stream has already been started.");
            }

            UriBuilder appLogUri = new UriBuilder(this.LogyardEndpoint);

            if (tail)
            {
                appLogUri.Path = string.Format(CultureInfo.InvariantCulture, "v2/apps/{0}/tail", appGuid);
            }
            else
            {
                appLogUri.Path = string.Format(CultureInfo.InvariantCulture, "v2/apps/{0}/recent", appGuid);
            }

            if (recentEntriesCount != -1)
            {
                appLogUri.Query = string.Format(CultureInfo.InvariantCulture, "num={0}", recentEntriesCount);
            }

            this.webSocket = new LogyardWebSocket();

            this.webSocket.DataReceived  += this.WebSocketMessageReceived;
            this.webSocket.ErrorReceived += this.WebSocketError;
            this.webSocket.StreamOpened  += this.WebSocketOpened;
            this.webSocket.StreamClosed  += this.WebSocketClosed;

            this.webSocket.Open(appLogUri.Uri, this.AuthenticationToken, this.HttpProxy, this.SkipCertificateValidation);
        }
Beispiel #3
0
        /// <summary>
        /// Starts streaming logs from Logyard for the specified app, without tailing.
        /// </summary>
        /// <param name="appGuid">The Cloud Foundry app unique identifier.</param>
        /// <param name="recentEntriesCount">The last number of log entries that will be returned to the stream. The -1 value will use the default value configured on the server.</param>
        /// <param name="tail">If set to <c>true</c> the application log files will be tailed.</param>
        /// <exception cref="System.ArgumentNullException">appGuid</exception>
        public void StartLogStream(string appGuid, int recentEntriesCount, bool tail)
        {
            if (appGuid == null)
            {
                throw new ArgumentNullException("appGuid");
            }

            if (recentEntriesCount < -1)
            {
                throw new ArgumentOutOfRangeException("recentEntriesCount", "Number of entries value must bust be >= -1.");
            }

            if (this.webSocket != null)
            {
                throw new InvalidOperationException("The log stream has already been started.");
            }

            UriBuilder appLogUri = new UriBuilder(this.LogyardEndpoint);

            if (tail)
            {
                appLogUri.Path = string.Format(CultureInfo.InvariantCulture, "v2/apps/{0}/tail", appGuid);
            }
            else
            {
                appLogUri.Path = string.Format(CultureInfo.InvariantCulture, "v2/apps/{0}/recent", appGuid);
            }

            if (recentEntriesCount != -1)
            {
                appLogUri.Query = string.Format(CultureInfo.InvariantCulture, "num={0}", recentEntriesCount);
            }

            this.webSocket = new LogyardWebSocket();

            this.webSocket.DataReceived += this.WebSocketMessageReceived;
            this.webSocket.ErrorReceived += this.WebSocketError;
            this.webSocket.StreamOpened += this.WebSocketOpened;
            this.webSocket.StreamClosed += this.WebSocketClosed;

            this.webSocket.Open(appLogUri.Uri, this.AuthenticationToken, this.HttpProxy, this.SkipCertificateValidation);
        }
Beispiel #4
0
 /// <summary>
 /// Stops the log stream.
 /// </summary>
 public void StopLogStream()
 {
     if (this.webSocket != null)
     {
         this.webSocket.Close();
         this.webSocket.Dispose();
         this.webSocket = null;
     }
 }