From b59ca45f2bcae72f018c637071af49733d664316 Mon Sep 17 00:00:00 2001 From: Ashwin Hariharan Date: Tue, 2 Aug 2022 15:54:43 +0530 Subject: [PATCH] Remove unnescesary commented Console.WriteLine and change Console.WriteLine to LOG.Debug (#4) --- .../Cumulocity.SDK.Client.csproj | 2 +- .../Autopoll/OperationsQueueHandler.cs | 4 ++-- .../Transport/CumulocityLongPollingTransport.cs | 10 +++------- .../Rest/API/Polling/AlteringRateResultPoller.cs | 1 - .../Rest/API/User/UserApiImpl.cs | 1 - .../cometd.NetStandard/Cometd.NetStandard.csproj | 6 +++++- .../cometd/client/BayeuxClient.cs | 15 +++------------ .../client/transport/LongPollingTransport.cs | 13 ++++++------- .../cometd/common/AbstractClientSession.cs | 8 ++++---- .../cometd/common/DictionaryMessage.cs | 4 +++- 10 files changed, 27 insertions(+), 37 deletions(-) diff --git a/REST-SDK/src/Cumulocity.SDK.Client/Cumulocity.SDK.Client.csproj b/REST-SDK/src/Cumulocity.SDK.Client/Cumulocity.SDK.Client.csproj index 7889a11..4e304ed 100644 --- a/REST-SDK/src/Cumulocity.SDK.Client/Cumulocity.SDK.Client.csproj +++ b/REST-SDK/src/Cumulocity.SDK.Client/Cumulocity.SDK.Client.csproj @@ -2,7 +2,7 @@ net47;netcoreapp3.1 8.0 - 10.6.6.28 + 10.6.6.29 Cumulocity Cumulocity Cumulocity diff --git a/REST-SDK/src/Cumulocity.SDK.Client/Rest/API/DeviceControl/Autopoll/OperationsQueueHandler.cs b/REST-SDK/src/Cumulocity.SDK.Client/Rest/API/DeviceControl/Autopoll/OperationsQueueHandler.cs index 1c2e4ee..8482da5 100644 --- a/REST-SDK/src/Cumulocity.SDK.Client/Rest/API/DeviceControl/Autopoll/OperationsQueueHandler.cs +++ b/REST-SDK/src/Cumulocity.SDK.Client/Rest/API/DeviceControl/Autopoll/OperationsQueueHandler.cs @@ -121,8 +121,8 @@ private void ThreadProc() catch (SDKException e) { // TODO Auto-generated catch block - Console.WriteLine(e.ToString()); - Console.Write(e.StackTrace); + LOG.Debug(e.ToString()); + LOG.Debug(e.StackTrace); } } Interlocked.Exchange(ref usingResource, 0); diff --git a/REST-SDK/src/Cumulocity.SDK.Client/Rest/API/Notification/Transport/CumulocityLongPollingTransport.cs b/REST-SDK/src/Cumulocity.SDK.Client/Rest/API/Notification/Transport/CumulocityLongPollingTransport.cs index 885cb57..9361fc8 100644 --- a/REST-SDK/src/Cumulocity.SDK.Client/Rest/API/Notification/Transport/CumulocityLongPollingTransport.cs +++ b/REST-SDK/src/Cumulocity.SDK.Client/Rest/API/Notification/Transport/CumulocityLongPollingTransport.cs @@ -114,8 +114,6 @@ public override void reset() public override void send(ITransportListener listener, IList messages) { - //Console.WriteLine(); - //Console.WriteLine("send({0} message(s))", messages.Count); String url = getURL(); if (_appendMessageType && messages.Count == 1 && messages[0].Meta) @@ -189,7 +187,6 @@ private static void GetRequestStreamCallback(IAsyncResult asynchronousResult) { // Convert the string into a byte array. byte[] byteArray = Encoding.UTF8.GetBytes(exchange.content); - //System.Diagnostics.Debug.WriteLine("Sending message(s): {0}", exchange.content); LOG.Debug(String.Format("{0} sending messages {1} ", DateTime.Now.ToString("HH:mm:ss.fff"), JsonConvert.SerializeObject(exchange.content))); @@ -233,7 +230,7 @@ private static void GetResponseCallback(IAsyncResult asynchronousResult) if (peeker == 32) { responseString = " "; - Console.WriteLine("HeartBeat"); + LOG.Debug("HeartBeat"); } else { @@ -241,7 +238,6 @@ private static void GetResponseCallback(IAsyncResult asynchronousResult) } } } - //Console.WriteLine("Received message(s): {0}", responseString); if (response.Cookies != null) foreach (Cookie cookie in response.Cookies) @@ -250,7 +246,7 @@ private static void GetResponseCallback(IAsyncResult asynchronousResult) response.Close(); } - Console.WriteLine(responseString); + LOG.Debug(responseString); exchange.messages = DictionaryMessage.parseMessages(responseString); exchange.listener.onMessages(exchange.messages); @@ -269,7 +265,7 @@ private static void TimeoutCallback(object state, bool timedOut) { if (timedOut) { - Console.WriteLine("Timeout"); + LOG.Debug("Timeout"); TransportExchange exchange = state as TransportExchange; if (exchange.request != null) exchange.request.Abort(); diff --git a/REST-SDK/src/Cumulocity.SDK.Client/Rest/API/Polling/AlteringRateResultPoller.cs b/REST-SDK/src/Cumulocity.SDK.Client/Rest/API/Polling/AlteringRateResultPoller.cs index 7114083..7ebfca9 100644 --- a/REST-SDK/src/Cumulocity.SDK.Client/Rest/API/Polling/AlteringRateResultPoller.cs +++ b/REST-SDK/src/Cumulocity.SDK.Client/Rest/API/Polling/AlteringRateResultPoller.cs @@ -25,7 +25,6 @@ public bool Start() { if (pollingTask == null) { - Console.WriteLine("Poller Start requested without pollingTask being Set"); LOG.Error("Poller Start requested without pollingTask being Set"); return false; } diff --git a/REST-SDK/src/Cumulocity.SDK.Client/Rest/API/User/UserApiImpl.cs b/REST-SDK/src/Cumulocity.SDK.Client/Rest/API/User/UserApiImpl.cs index e2d5c35..76e908d 100644 --- a/REST-SDK/src/Cumulocity.SDK.Client/Rest/API/User/UserApiImpl.cs +++ b/REST-SDK/src/Cumulocity.SDK.Client/Rest/API/User/UserApiImpl.cs @@ -56,7 +56,6 @@ public UserRepresentation GetUser(string tenant, string user) @params[REALM] = tenant; @params[USER_NAME] = user; string url = templateUrlParser.replacePlaceholdersWithParams(usersApiRepresentation.UserByName, @params); - Console.WriteLine(url); return restConnector.Get(url, UserMediaType.USER, typeof(UserRepresentation)); } diff --git a/REST-SDK/src/cometd.NetStandard/Cometd.NetStandard.csproj b/REST-SDK/src/cometd.NetStandard/Cometd.NetStandard.csproj index d15d617..8396ac7 100644 --- a/REST-SDK/src/cometd.NetStandard/Cometd.NetStandard.csproj +++ b/REST-SDK/src/cometd.NetStandard/Cometd.NetStandard.csproj @@ -4,7 +4,7 @@ net47;net48;netcoreapp3.1 Cometd 7.3 - 1006.6.0 + 1006.6.1 true Cumulocity Cumulocity @@ -19,6 +19,10 @@ + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/REST-SDK/src/cometd.NetStandard/cometd/client/BayeuxClient.cs b/REST-SDK/src/cometd.NetStandard/cometd/client/BayeuxClient.cs index 0299a43..0d4bdc3 100644 --- a/REST-SDK/src/cometd.NetStandard/cometd/client/BayeuxClient.cs +++ b/REST-SDK/src/cometd.NetStandard/cometd/client/BayeuxClient.cs @@ -10,6 +10,7 @@ using System.Linq; using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using Cometd.Logging; namespace Cometd.Client { @@ -35,12 +36,10 @@ public class BayeuxClient : AbstractClientSession, IBayeux private static Mutex stateUpdateInProgressMutex = new Mutex(); private int stateUpdateInProgress; private AutoResetEvent stateChanged = new AutoResetEvent(false); - + private static readonly ILog LOG = LogProvider.For(); public BayeuxClient(String url, IList transports) { - //logger = Log.getLogger(GetType().FullName + "@" + this.GetHashCode()); - //Console.WriteLine(GetType().FullName + "@" + this.GetHashCode()); handshakeListener = new HandshakeTransportListener(this); connectListener = new ConnectTransportListener(this); @@ -180,7 +179,6 @@ public override void handshake(IDictionary handshakeFields) // Pick the first transport for the handshake, it will renegotiate if not right ClientTransport initialTransport = transportRegistry.getTransport(allowedTransports[0]); initialTransport.init(); - //Console.WriteLine("Using initial transport {0} from {1}", initialTransport.Name, Print.List(allowedTransports)); updateBayeuxClientState( delegate(BayeuxClientState oldState) @@ -220,7 +218,6 @@ protected bool sendHandshake() if (message.Id == null) message.Id = newMessageId(); - //Console.WriteLine("Handshaking with extra fields {0}, transport {1}", Print.Dictionary(bayeuxClientState.handshakeFields), Print.Dictionary(bayeuxClientState.transport as IDictionary)); bayeuxClientState.send(handshakeListener, message); return true; } @@ -387,10 +384,7 @@ protected void processHandshake(IMutableMessage handshake) // @@ax: I think this should be able to return a list of objects? Object serverTransportObject; handshake.TryGetValue(Message_Fields.SUPPORTED_CONNECTION_TYPES_FIELD, out serverTransportObject); - //IList serverTransports = serverTransportObject as IList; - //Console.WriteLine("Supported transport: {0}", serverTransport); var serverTransports = ((JArray)serverTransportObject).Select(x => (string)x).ToList(); - //IList serverTransports = JsonConvert.DeserializeObject>(serverTransportObject as string); IList negotiatedTransports = transportRegistry.Negotiate(serverTransports, BAYEUX_VERSION); ClientTransport newTransport = negotiatedTransports.Count == 0 ? null : negotiatedTransports[0]; @@ -640,12 +634,10 @@ protected void enqueueSend(IMutableMessage message) IList messages = new List(); messages.Add(message); bool sent = sendMessages(messages); - //Console.WriteLine("{0} message {1}", sent?"Sent":"Failed", message); } else { messageQueue.Enqueue(message); - //Console.WriteLine("Enqueued message {0} (batching: {1})", message, this.Batching); } } @@ -679,7 +671,7 @@ public void onMessages(IList messages) public virtual void onFailure(Exception x, IList messages) { - Console.WriteLine("{0}", x.ToString()); + LOG.Debug("{0}", x.ToString()); } private void updateBayeuxClientState(BayeuxClientStateUpdater_createDelegate create) @@ -702,7 +694,6 @@ private void updateBayeuxClientState(BayeuxClientStateUpdater_createDelegate cre if (!oldState.isUpdateableTo(newState)) { - //Console.WriteLine("State not updateable : {0} -> {1}", oldState, newState); return; } diff --git a/REST-SDK/src/cometd.NetStandard/cometd/client/transport/LongPollingTransport.cs b/REST-SDK/src/cometd.NetStandard/cometd/client/transport/LongPollingTransport.cs index e9708b0..392073c 100644 --- a/REST-SDK/src/cometd.NetStandard/cometd/client/transport/LongPollingTransport.cs +++ b/REST-SDK/src/cometd.NetStandard/cometd/client/transport/LongPollingTransport.cs @@ -1,5 +1,6 @@ using Cometd.Bayeux; using Cometd.Common; +using Cometd.Logging; using Newtonsoft.Json; using System; using System.Collections.Generic; @@ -26,6 +27,8 @@ public class LongPollingTransport : HttpClientTransport private List transportQueue = new List(); + private static readonly ILog LOG = LogProvider.For(); + public LongPollingTransport(IDictionary options) : base("long-polling", options) { @@ -105,8 +108,6 @@ public override void reset() public override void send(ITransportListener listener, IList messages) { - //Console.WriteLine(); - //Console.WriteLine("send({0} message(s))", messages.Count); String url = getURL(); if (_appendMessageType && messages.Count == 1 && messages[0].Meta) @@ -162,8 +163,7 @@ private static void GetRequestStreamCallback(IAsyncResult asynchronousResult) { // Convert the string into a byte array. byte[] byteArray = Encoding.UTF8.GetBytes(exchange.content); - Console.WriteLine("Sending message(s): {0}", exchange.content); - //Console.WriteLine("Sending message(s): {0}", exchange.content); + LOG.Debug("Sending message(s): {0}", exchange.content); // Write to the request stream. postStream.Write(byteArray, 0, exchange.content.Length); @@ -202,7 +202,6 @@ private static void GetResponseCallback(IAsyncResult asynchronousResult) using (StreamReader streamRead = new StreamReader(streamResponse)) responseString = streamRead.ReadToEnd(); } - //Console.WriteLine("Received message(s): {0}", responseString); if (response.Cookies != null) foreach (Cookie cookie in response.Cookies) @@ -211,7 +210,7 @@ private static void GetResponseCallback(IAsyncResult asynchronousResult) response.Close(); } - Console.WriteLine(responseString); + LOG.Debug(responseString); exchange.messages = DictionaryMessage.parseMessages(responseString); exchange.listener.onMessages(exchange.messages); @@ -230,7 +229,7 @@ private static void TimeoutCallback(object state, bool timedOut) { if (timedOut) { - Console.WriteLine("Timeout"); + LOG.Debug("Timeout"); TransportExchange exchange = state as TransportExchange; if (exchange.request != null) exchange.request.Abort(); diff --git a/REST-SDK/src/cometd.NetStandard/cometd/common/AbstractClientSession.cs b/REST-SDK/src/cometd.NetStandard/cometd/common/AbstractClientSession.cs index 285984a..e814edd 100644 --- a/REST-SDK/src/cometd.NetStandard/cometd/common/AbstractClientSession.cs +++ b/REST-SDK/src/cometd.NetStandard/cometd/common/AbstractClientSession.cs @@ -4,6 +4,7 @@ using System.Linq; using Cometd.Bayeux; using Cometd.Bayeux.Client; +using Cometd.Logging; namespace Cometd.Common { @@ -18,6 +19,7 @@ public abstract class AbstractClientSession : IClientSession private Dictionary _channels = new Dictionary(); private int _batch; private int _idGen = 0; + private static readonly ILog LOG = LogProvider.For(); protected AbstractClientSession() { @@ -380,8 +382,7 @@ public void notifyMessageListeners(IMessage message) } catch (Exception x) { - Console.WriteLine("{0}", x); - //logger.info(x); + LOG.Debug("{0}", x); } } } @@ -399,8 +400,7 @@ public void notifyMessageListeners(IMessage message) } catch (System.Exception x) { - Console.WriteLine("{0}", x); - //logger.info(x); + LOG.Debug("{0}", x); } } } diff --git a/REST-SDK/src/cometd.NetStandard/cometd/common/DictionaryMessage.cs b/REST-SDK/src/cometd.NetStandard/cometd/common/DictionaryMessage.cs index 4416645..9ba9bb1 100644 --- a/REST-SDK/src/cometd.NetStandard/cometd/common/DictionaryMessage.cs +++ b/REST-SDK/src/cometd.NetStandard/cometd/common/DictionaryMessage.cs @@ -1,4 +1,5 @@ using Cometd.Bayeux; +using Cometd.Logging; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using System; @@ -10,6 +11,7 @@ namespace Cometd.Common public class DictionaryMessage : Dictionary, IMutableMessage { private const long serialVersionUID = 4318697940670212190L; + private static readonly ILog LOG = LogProvider.For(); public DictionaryMessage() { @@ -212,7 +214,7 @@ public static IList parseMessages(String content) } catch (Exception e) { - Console.WriteLine("Exception when parsing json {0}", e); + LOG.Debug("Exception when parsing json {0}", e); } IList messages = new List();