Skip to content

Commit

Permalink
Replace console.log with console.warn
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles-Schleich committed Oct 24, 2024
1 parent 198f2c4 commit 0306aaa
Show file tree
Hide file tree
Showing 14 changed files with 53 additions and 53 deletions.
6 changes: 3 additions & 3 deletions zenoh-ts/examples/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ async function main() {
let count = 0;
while (true) {
await sleep(1000 * 100);
console.log("Main Loop tick ", count);
console.warn("Main Loop tick ", count);
count = count + 1;
}
}

main()
.then(() => console.log("Done"))
.then(() => console.warn("Done"))
.catch((e) => {
console.log(e);
console.warn(e);
throw e;
});

Expand Down
12 changes: 6 additions & 6 deletions zenoh-ts/examples/src/z_get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ export async function get() {
let resp = reply.result();
if (resp instanceof Sample) {
let sample: Sample = resp;
console.log(">> Received ('", sample.keyexpr(), ":", sample.payload().deserialize(deserialize_string),"')");
console.warn(">> Received ('", sample.keyexpr(), ":", sample.payload().deserialize(deserialize_string),"')");
} else {
let reply_error: ReplyError = resp;
console.log(">> Received (ERROR: '", reply_error.payload().deserialize(deserialize_string), "')");
console.warn(">> Received (ERROR: '", reply_error.payload().deserialize(deserialize_string), "')");
}
};

console.log("Start z_get")
console.warn("Start z_get")
await session.get("demo/example/**", get_callback);

// Poll receiever
Expand All @@ -46,15 +46,15 @@ export async function get() {
let reply = await receiver.receive();
while (reply != RecvErr.Disconnected) {
if (reply == RecvErr.MalformedReply) {
console.log("MalformedReply");
console.warn("MalformedReply");
} else {
let resp = reply.result();
if (resp instanceof Sample) {
let sample: Sample = resp;
console.log(">> Received ('", sample.keyexpr(), ":", sample.payload().deserialize(deserialize_string),"')");
console.warn(">> Received ('", sample.keyexpr(), ":", sample.payload().deserialize(deserialize_string),"')");
} else {
let reply_error: ReplyError = resp;
console.log(">> Received (ERROR: '{", reply_error.payload().deserialize(deserialize_string), "}')");
console.warn(">> Received (ERROR: '{", reply_error.payload().deserialize(deserialize_string), "}')");
}
}
reply = await receiver.receive();
Expand Down
4 changes: 2 additions & 2 deletions zenoh-ts/examples/src/z_ping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export async function ping() {
);

// Warm up
console.log("Warming up for 5 seconds...");
console.warn("Warming up for 5 seconds...");

let startTime = new Date();
let data = [122, 101, 110, 111, 104];
Expand All @@ -52,7 +52,7 @@ export async function ping() {

for (let i = 0; i < samples_out.length; i++) {
let rtt = samples_out[i];
console.log(
console.warn(
data.length +
"bytes: seq=" +
i +
Expand Down
4 changes: 2 additions & 2 deletions zenoh-ts/examples/src/z_pub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ export async function pub() {
for (let idx = 0; idx < Number.MAX_VALUE; idx++) {
let buf = `[${idx}] ${payload}`;

console.log("Block statement execution no : " + idx);
console.log(`Putting Data ('${key_expr}': '${buf}')...`);
console.warn("Block statement execution no : " + idx);
console.warn(`Putting Data ('${key_expr}': '${buf}')...`);
publisher.put(buf, Encoding.TEXT_PLAIN, "attachment");
await sleep(1000);

Expand Down
2 changes: 1 addition & 1 deletion zenoh-ts/examples/src/z_put.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import "./webpage.ts";
import { Config, Session } from "@ZettaScaleLabs/zenoh-ts";

export async function put() {
console.log('Running Zenoh Put !');
console.warn('Running Zenoh Put !');

const session = await Session.open(new Config ("ws/127.0.0.1:10000"));
session.put("demo/example/zenoh-ts-put", "Put from Typescript!");
Expand Down
14 changes: 7 additions & 7 deletions zenoh-ts/examples/src/z_queryable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { Config, KeyExpr, Query, Queryable, Session, ZBytes } from "@ZettaScaleL
export async function queryable() {
const session = await Session.open(new Config ("ws/127.0.0.1:10000"));
let key_expr = new KeyExpr("demo/example/zenoh-ts-queryable");
console.log("Declare Queryable on KeyExpr:", key_expr.toString());
console.warn("Declare Queryable on KeyExpr:", key_expr.toString());

const payload = [122, 101, 110, 111, 104];

Expand All @@ -30,14 +30,14 @@ export async function queryable() {
let zbytes: ZBytes | undefined = query.payload();

if (zbytes == null) {
console.log!(`>> [Queryable ] Received Query ${query.selector()}`);
console.warn!(`>> [Queryable ] Received Query ${query.selector()}`);
} else {
console.log!(
console.warn!(
`>> [Queryable ] Received Query ${query.selector()} with payload '${zbytes}'`,
);
}

console.log(
console.warn(
`>> [Queryable ] Responding ${key_expr.toString()} with payload '${payload}'`,
);
query.reply(key_expr, payload);
Expand All @@ -62,14 +62,14 @@ export async function queryable() {
let zbytes: ZBytes | undefined = query.payload();

if (zbytes == null) {
console.log!(`>> [Queryable ] Received Query ${query.selector().toString()}`);
console.warn!(`>> [Queryable ] Received Query ${query.selector().toString()}`);
} else {
console.log!(
console.warn!(
`>> [Queryable ] Received Query ${query.selector()} with payload '${zbytes.buffer()}'`,
);
}

console.log(
console.warn(
`>> [Queryable ] Responding ${key_expr.toString()} with payload '${payload}'`,
);
query.reply(key_expr, payload);
Expand Down
8 changes: 4 additions & 4 deletions zenoh-ts/examples/src/z_sub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export async function sub() {
const session = await Session.open(new Config ("ws/127.0.0.1:10000"));

const callback = async function (sample: Sample): Promise<void> {
console.log!(
console.warn!(
">> [Subscriber] Received " +
sample.kind() + " ('" +
sample.keyexpr() + "': '" +
Expand All @@ -32,7 +32,7 @@ export async function sub() {
};

let key_expr = new KeyExpr("demo/example/zenoh-ts-sub");
console.log("Declare Subscriber ", key_expr.toString());
console.warn("Declare Subscriber ", key_expr.toString());
// Callback Subscriber take a callback which will be called upon every sample received.
let callback_subscriber: Subscriber = await session.declare_subscriber(
key_expr,
Expand All @@ -41,15 +41,15 @@ export async function sub() {

await sleep(1000 * 3);
callback_subscriber.undeclare();
console.log("Undeclare callback_subscriber");
console.warn("Undeclare callback_subscriber");

// Poll Subscribers will only consume data on calls to receieve()
// This means that interally the FIFO queue will fill up to the point that new values will be dropped
// The dropping of these values occurs in the Remote-API Plugin
let poll_subscriber: Subscriber = await session.declare_subscriber("demo/example/zenoh-ts-sub", new RingChannel(10));
let sample = await poll_subscriber.receive();
while (sample != undefined) {
console.log!(
console.warn!(
">> [Subscriber] Received " +
sample.kind() + " ('" +
sample.keyexpr() + "': '" +
Expand Down
8 changes: 4 additions & 4 deletions zenoh-ts/examples/src/z_sub_thr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,19 @@ class Stats {
print_round() {
let elapsed_ms = Date.now() - this.round_start;
let throughput = (this.round_size) / (elapsed_ms / 1000);
console.log(throughput, " msg/s");
console.warn(throughput, " msg/s");
}
}

export async function thr() {
console.log("Open Session");
console.warn("Open Session");
const session : Session = await Session.open(new Config ("ws/127.0.0.1:10000"));
let stats = new Stats(100000);
const subscriber_callback = async function (_sample: Sample): Promise<void> {
stats.increment();
};

console.log("Declare subscriber");
console.warn("Declare subscriber");
await session.declare_subscriber(
"test/thr",
subscriber_callback,
Expand All @@ -74,7 +74,7 @@ export async function thr() {
while (true) {
var seconds = 100;
await sleep(1000 * seconds);
console.log("Main Loop ? ", count);
console.warn("Main Loop ? ", count);
count = count + 1;
}
}
Expand Down
4 changes: 2 additions & 2 deletions zenoh-ts/src/pubsub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export class Subscriber {
*/
async receive(): Promise<Sample | void> {
if (this.callback_subscriber === true) {
console.log("Cannot call `receive()` on Subscriber created with callback:");
console.warn("Cannot call `receive()` on Subscriber created with callback:");
return;
}

Expand All @@ -90,7 +90,7 @@ export class Subscriber {
if (opt_sample_ws != undefined) {
return Sample_from_SampleWS(opt_sample_ws);
} else {
console.log("Receieve returned unexpected void from RemoteSubscriber");
console.warn("Receieve returned unexpected void from RemoteSubscriber");
return;
}
}
Expand Down
4 changes: 2 additions & 2 deletions zenoh-ts/src/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export class Queryable {

if (this._callback_queryable === true) {
let message = "Cannot call `receive()` on Subscriber created with callback:";
console.log(message);
console.warn(message);
return
}

Expand All @@ -84,7 +84,7 @@ export class Queryable {
let reply_tx = opt_query_ws[1];
return QueryWS_to_Query(query_ws, reply_tx);
} else {
console.log("Receieve returned unexpected void from RemoteQueryable");
console.warn("Receieve returned unexpected void from RemoteQueryable");
return;
}
}
Expand Down
10 changes: 5 additions & 5 deletions zenoh-ts/src/remote_api/pubsub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export class RemotePublisher {
"` id:`" +
this.publisher_id +
"` already undeclared";
console.log(message);
console.warn(message);
return;
}

Expand Down Expand Up @@ -93,7 +93,7 @@ export class RemotePublisher {
"` id:`" +
this.publisher_id +
"` already undeclared";
console.log(message);
console.warn(message);
return;
}
this.undeclared = true;
Expand Down Expand Up @@ -163,7 +163,7 @@ export class RemoteSubscriber {

async receive(): Promise<SampleWS | void> {
if (this.undeclared == true) {
console.log("Subscriber keyexpr:`" +
console.warn("Subscriber keyexpr:`" +
this.key_expr +
"` id:`" +
this.subscriber_id +
Expand All @@ -172,7 +172,7 @@ export class RemoteSubscriber {
}

if (this.callback != undefined) {
console.log("Cannot Call receive on Subscriber created with callback:`" +
console.warn("Cannot Call receive on Subscriber created with callback:`" +
this.key_expr +
"` id:`" +
this.subscriber_id +
Expand All @@ -185,7 +185,7 @@ export class RemoteSubscriber {

undeclare() {
if (this.undeclared == true) {
console.log("Subscriber keyexpr:`" +
console.warn("Subscriber keyexpr:`" +
this.key_expr +
"` id:`" +
this.subscriber_id +
Expand Down
6 changes: 3 additions & 3 deletions zenoh-ts/src/remote_api/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export class RemoteQueryable {

async receive(): Promise<[QueryWS, SimpleChannel<QueryReplyWS>] | void> {
if (this.undeclared == true) {
console.log("Queryable keyexpr:`" +
console.warn("Queryable keyexpr:`" +
this.key_expr +
"` id:`" +
this.queryable_id +
Expand All @@ -116,7 +116,7 @@ export class RemoteQueryable {
}

if (this.callback != undefined) {
console.log("Cannot Call receive on Queryable created with callback:`" +
console.warn("Cannot Call receive on Queryable created with callback:`" +
this.key_expr +
"` id:`" +
this.queryable_id +
Expand All @@ -129,7 +129,7 @@ export class RemoteQueryable {

undeclare() {
if (this.undeclared == true) {
console.log("Queryable keyexpr:`" +
console.warn("Queryable keyexpr:`" +
this.key_expr +
"` id:`" +
this.queryable_id +
Expand Down
20 changes: 10 additions & 10 deletions zenoh-ts/src/remote_api/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export class RemoteSession {
websocket_connected = true;
} else {
ws = new WebSocket(websocket_endpoint);
console.log("Restart connection");
console.warn("Restart connection");
}
}

Expand Down Expand Up @@ -348,7 +348,7 @@ export class RemoteSession {
) as RemoteAPIMsg;

if ("Session" in remote_api_message) {
console.log("Continue Ignore Session Messages");
console.warn("Continue Ignore Session Messages");
continue;
} else if ("Control" in remote_api_message) {
this.handle_control_message(remote_api_message["Control"]);
Expand All @@ -363,12 +363,12 @@ export class RemoteSession {
);
}
}
console.log("Closed");
console.warn("Closed");
}

private async handle_control_message(control_msg: ControlMsg) {
if (typeof control_msg === "string") {
console.log("unhandled Control Message:", control_msg);
console.warn("unhandled Control Message:", control_msg);
} else if (typeof control_msg === "object") {
if ("Session" in control_msg) {
this.session = control_msg["Session"];
Expand All @@ -391,7 +391,7 @@ export class RemoteSession {
let sample: SampleWS = data_msg["Sample"][0];
channel.send(sample);
} else {
console.log("Subscrption UUID not in map", subscription_uuid);
console.warn("Subscrption UUID not in map", subscription_uuid);
}
} else if ("GetReply" in data_msg) {
let get_reply: ReplyWS = data_msg["GetReply"];
Expand All @@ -412,17 +412,17 @@ export class RemoteSession {
let query = queryable_msg.Query.query;
channel.send(query);
} else {
console.log("Queryable Message UUID not in map", queryable_uuid);
console.warn("Queryable Message UUID not in map", queryable_uuid);
}
} else if ("Reply" in queryable_msg) {
// Server
console.log("Client should not receive Reply in Queryable Message");
console.log("Replies to get queries should come via Get Reply");
console.warn("Client should not receive Reply in Queryable Message");
console.warn("Replies to get queries should come via Get Reply");
} else {
console.log("Queryable message Variant not recognized");
console.warn("Queryable message Variant not recognized");
}
} else {
console.log("Data Message not recognized Expected Variant", data_msg);
console.warn("Data Message not recognized Expected Variant", data_msg);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions zenoh-ts/src/sample.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export function priority_from_int(prio_u8: number): Priority {
case 7:
return Priority.BACKGROUND;
default:
console.log("Unknown Priority Variant, default to Data");
console.warn("Unknown Priority Variant, default to Data");
return Priority.DATA;
}
}
Expand Down Expand Up @@ -334,7 +334,7 @@ export function SampleWS_from_Sample(
} else if (sample.kind() == SampleKind.PUT) {
sample_kind = "Put";
} else {
console.log(
console.warn(
"Sample Kind not PUT | DELETE, defaulting to PUT: ",
sample.kind(),
);
Expand Down

0 comments on commit 0306aaa

Please sign in to comment.