Skip to content

Commit

Permalink
Remove unnescesary commented Console.WriteLine and change Console.Wri…
Browse files Browse the repository at this point in the history
…teLine to LOG.Debug (#4)
  • Loading branch information
ashhSAG93 committed Aug 2, 2022
1 parent 1e355d5 commit b59ca45
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFrameworks>net47;netcoreapp3.1</TargetFrameworks>
<LangVersion>8.0</LangVersion>
<Version>10.6.6.28</Version>
<Version>10.6.6.29</Version>
<Authors>Cumulocity</Authors>
<Product>Cumulocity</Product>
<Copyright>Cumulocity</Copyright>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,6 @@ public override void reset()

public override void send(ITransportListener listener, IList<IMutableMessage> messages)
{
//Console.WriteLine();
//Console.WriteLine("send({0} message(s))", messages.Count);
String url = getURL();

if (_appendMessageType && messages.Count == 1 && messages[0].Meta)
Expand Down Expand Up @@ -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)));

Expand Down Expand Up @@ -233,15 +230,14 @@ private static void GetResponseCallback(IAsyncResult asynchronousResult)
if (peeker == 32)
{
responseString = " ";
Console.WriteLine("HeartBeat");
LOG.Debug("HeartBeat");
}
else
{
responseString = streamRead.ReadToEnd();
}
}
}
//Console.WriteLine("Received message(s): {0}", responseString);

if (response.Cookies != null)
foreach (Cookie cookie in response.Cookies)
Expand All @@ -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);
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<UserRepresentation>(url, UserMediaType.USER, typeof(UserRepresentation));
}

Expand Down
6 changes: 5 additions & 1 deletion REST-SDK/src/cometd.NetStandard/Cometd.NetStandard.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>net47;net48;netcoreapp3.1</TargetFrameworks>
<RootNamespace>Cometd</RootNamespace>
<LangVersion>7.3</LangVersion>
<Version>1006.6.0</Version>
<Version>1006.6.1</Version>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<Authors>Cumulocity</Authors>
<Company>Cumulocity</Company>
Expand All @@ -19,6 +19,10 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="LibLog" Version="5.0.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="System.ServiceModel.Web" Version="1.0.0" />
</ItemGroup>
Expand Down
15 changes: 3 additions & 12 deletions REST-SDK/src/cometd.NetStandard/cometd/client/BayeuxClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using System.Linq;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Cometd.Logging;

namespace Cometd.Client
{
Expand All @@ -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<BayeuxClient>();

public BayeuxClient(String url, IList<ClientTransport> transports)
{
//logger = Log.getLogger(GetType().FullName + "@" + this.GetHashCode());
//Console.WriteLine(GetType().FullName + "@" + this.GetHashCode());

handshakeListener = new HandshakeTransportListener(this);
connectListener = new ConnectTransportListener(this);
Expand Down Expand Up @@ -180,7 +179,6 @@ public override void handshake(IDictionary<String, Object> 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)
Expand Down Expand Up @@ -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<String, Object>));
bayeuxClientState.send(handshakeListener, message);
return true;
}
Expand Down Expand Up @@ -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<Object> serverTransports = serverTransportObject as IList<Object>;
//Console.WriteLine("Supported transport: {0}", serverTransport);
var serverTransports = ((JArray)serverTransportObject).Select(x => (string)x).ToList();
//IList<Object> serverTransports = JsonConvert.DeserializeObject<IList<Object>>(serverTransportObject as string);

IList<ClientTransport> negotiatedTransports = transportRegistry.Negotiate(serverTransports, BAYEUX_VERSION);
ClientTransport newTransport = negotiatedTransports.Count == 0 ? null : negotiatedTransports[0];
Expand Down Expand Up @@ -640,12 +634,10 @@ protected void enqueueSend(IMutableMessage message)
IList<IMutableMessage> messages = new List<IMutableMessage>();
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);
}
}

Expand Down Expand Up @@ -679,7 +671,7 @@ public void onMessages(IList<IMutableMessage> messages)

public virtual void onFailure(Exception x, IList<IMessage> messages)
{
Console.WriteLine("{0}", x.ToString());
LOG.Debug("{0}", x.ToString());
}

private void updateBayeuxClientState(BayeuxClientStateUpdater_createDelegate create)
Expand All @@ -702,7 +694,6 @@ private void updateBayeuxClientState(BayeuxClientStateUpdater_createDelegate cre

if (!oldState.isUpdateableTo(newState))
{
//Console.WriteLine("State not updateable : {0} -> {1}", oldState, newState);
return;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Cometd.Bayeux;
using Cometd.Common;
using Cometd.Logging;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
Expand All @@ -26,6 +27,8 @@ public class LongPollingTransport : HttpClientTransport

private List<LongPollingRequest> transportQueue = new List<LongPollingRequest>();

private static readonly ILog LOG = LogProvider.For<BayeuxClient>();

public LongPollingTransport(IDictionary<String, Object> options)
: base("long-polling", options)
{
Expand Down Expand Up @@ -105,8 +108,6 @@ public override void reset()

public override void send(ITransportListener listener, IList<IMutableMessage> messages)
{
//Console.WriteLine();
//Console.WriteLine("send({0} message(s))", messages.Count);
String url = getURL();

if (_appendMessageType && messages.Count == 1 && messages[0].Meta)
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand All @@ -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);
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Linq;
using Cometd.Bayeux;
using Cometd.Bayeux.Client;
using Cometd.Logging;

namespace Cometd.Common
{
Expand All @@ -18,6 +19,7 @@ public abstract class AbstractClientSession : IClientSession
private Dictionary<String, AbstractSessionChannel> _channels = new Dictionary<String, AbstractSessionChannel>();
private int _batch;
private int _idGen = 0;
private static readonly ILog LOG = LogProvider.For<AbstractClientSession>();

protected AbstractClientSession()
{
Expand Down Expand Up @@ -380,8 +382,7 @@ public void notifyMessageListeners(IMessage message)
}
catch (Exception x)
{
Console.WriteLine("{0}", x);
//logger.info(x);
LOG.Debug("{0}", x);
}
}
}
Expand All @@ -399,8 +400,7 @@ public void notifyMessageListeners(IMessage message)
}
catch (System.Exception x)
{
Console.WriteLine("{0}", x);
//logger.info(x);
LOG.Debug("{0}", x);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Cometd.Bayeux;
using Cometd.Logging;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
Expand All @@ -10,6 +11,7 @@ namespace Cometd.Common
public class DictionaryMessage : Dictionary<String, Object>, IMutableMessage
{
private const long serialVersionUID = 4318697940670212190L;
private static readonly ILog LOG = LogProvider.For<DictionaryMessage>();

public DictionaryMessage()
{
Expand Down Expand Up @@ -212,7 +214,7 @@ public static IList<IMutableMessage> parseMessages(String content)
}
catch (Exception e)
{
Console.WriteLine("Exception when parsing json {0}", e);
LOG.Debug("Exception when parsing json {0}", e);
}

IList<IMutableMessage> messages = new List<IMutableMessage>();
Expand Down

0 comments on commit b59ca45

Please sign in to comment.