Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use of pinojs as logger instead of ulog #237

Merged
merged 4 commits into from
Oct 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions __tests__/Logger.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import type {Reactor} from "../src/core/internal";
import {
App,
Log,
LogLevel,
loggingCLAType,
booleanCLAType,
stringCLAType,
Expand All @@ -26,9 +25,9 @@ describe("Logger functions", function () {

describe("Test for Logger", () => {
it("DEBUG Log", () => {
Log.global.level = LogLevel.DEBUG;
Log.setLevel(Log.LogLevel.DEBUG);

console.log("Log level is " + Log.global.level);
console.log("Log level is " + Log.globalLogger.level);
Log.getInstance("test module");
Log.debug(null, () => "test");
Log.debug(null, () => "test", "test module");
Expand Down Expand Up @@ -65,7 +64,7 @@ describe("Test for Logger", () => {
expect(Log.log).toHaveBeenCalledTimes(2);
expect(Log.warn).toHaveBeenCalledTimes(2);

console.log(Log.global.level);
console.log(Log.globalLogger.level);
});
});

Expand All @@ -75,7 +74,7 @@ describe("Command Line Arguments Helper Functions Tests", () => {
expect(loggingCLAType("")).toBeNull;
});
test("log level check", () => {
expect(loggingCLAType("ERROR")).toBe(1);
expect(loggingCLAType("ERROR")).toBe(Log.LogLevel.ERROR.valueOf());
});
test("boolean test for command line argument parsing", () => {
expect(booleanCLAType("true")).toBe(true);
Expand Down
4 changes: 2 additions & 2 deletions __tests__/OutputGet.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ class OutputGetTest extends App {
failure: () => void
) {
super(timeout, true, false, success, failure);
Log.global.debug(">>>>>>>>----" + this.util);
Log.globalLogger.debug(">>>>>>>>----" + this.util);
this.addReaction([this.t], [this.writable(this.o)], function (this, o) {
Log.global.debug(">>>>>>>>>>being triggered>>>>>>>>>>>");
Log.globalLogger.debug(">>>>>>>>>>being triggered>>>>>>>>>>>");
if (o.get() != null) {
throw new Error(
"Calling get on an output before it has been set does not return null"
Expand Down
24 changes: 12 additions & 12 deletions __tests__/dependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ describe("Manually constructed precedence graphs", () => {
graph.removeNode(nodes[1]);
expect(graph.size()[0]).toEqual(5); // V
expect(graph.size()[1]).toEqual(3); // E
Log.global.debug(graph.toString());
Log.globalLogger.debug(graph.toString());
expect(graph.toString()).toBe(
dontIndent`graph
0["app.R[R3]"]
Expand All @@ -165,7 +165,7 @@ describe("Manually constructed precedence graphs", () => {
graph.addEdge(nodes[3], nodes[2]);
expect(graph.size()[0]).toEqual(6); // V
expect(graph.size()[1]).toEqual(4); // E
Log.global.debug(graph.toString());
Log.globalLogger.debug(graph.toString());
expect(graph.toString()).toBe(
dontIndent`graph
0["app.R[R3]"]
Expand Down Expand Up @@ -195,7 +195,7 @@ describe("Manually constructed precedence graphs", () => {
it("introduce a cycle", () => {
graph.addEdge(nodes[2], nodes[5]);
expect(graph.updatePriorities(false)).toBeFalsy();
Log.global.debug(graph.toString());
Log.globalLogger.debug(graph.toString());
});
});

Expand All @@ -217,18 +217,18 @@ describe("ReactionQ", () => {
var reactionQ = new PrioritySet<Priority>();

for (let i = 0; i < 6; i++) {
Log.global.debug(
Log.globalLogger.debug(
"Pushing node: " + i + " with prio: " + nodes[i].getPriority()
);
reactionQ.push(nodes[i]);
}

// duplicate insertions
Log.global.debug(
Log.globalLogger.debug(
"Pushing duplicate node with prio: " + nodes[5].getPriority()
);
reactionQ.push(nodes[5]);
Log.global.debug(
Log.globalLogger.debug(
"Pushing duplicate node with prio: " + nodes[1].getPriority()
);
reactionQ.push(nodes[1]);
Expand All @@ -237,7 +237,7 @@ describe("ReactionQ", () => {
const r = reactionQ.pop();
for (let i = 0; i < 6; i++) {
if (Object.is(r, nodes[i])) {
Log.global.debug(
Log.globalLogger.debug(
"Found matching node: " + i + " with prio: " + nodes[i].getPriority()
);
}
Expand All @@ -251,7 +251,7 @@ describe("ReactionQ", () => {

for (let i = 0; i < 6; i++) {
if (Object.is(r, nodes[i])) {
Log.global.debug(
Log.globalLogger.debug(
"Found matching node: " + i + " with prio: " + nodes[i].getPriority()
);
}
Expand All @@ -264,7 +264,7 @@ describe("ReactionQ", () => {
const r = reactionQ.pop();
for (let i = 0; i < 6; i++) {
if (Object.is(r, nodes[i])) {
Log.global.debug(
Log.globalLogger.debug(
"Found matching node: " + i + " with prio: " + nodes[i].getPriority()
);
}
Expand All @@ -277,7 +277,7 @@ describe("ReactionQ", () => {
const r = reactionQ.pop();
for (let i = 0; i < 6; i++) {
if (Object.is(r, nodes[i])) {
Log.global.debug(
Log.globalLogger.debug(
"Found matching node: " + i + " with prio: " + nodes[i].getPriority()
);
}
Expand All @@ -290,7 +290,7 @@ describe("ReactionQ", () => {
const r = reactionQ.pop();
for (let i = 0; i < 6; i++) {
if (Object.is(r, nodes[i])) {
Log.global.debug(
Log.globalLogger.debug(
"Found matching node: " + i + " with prio: " + nodes[i].getPriority()
);
}
Expand All @@ -303,7 +303,7 @@ describe("ReactionQ", () => {
const r = reactionQ.pop();
for (let i = 0; i < 6; i++) {
if (Object.is(r, nodes[i])) {
Log.global.debug(
Log.globalLogger.debug(
"Found matching node: " + i + " with prio: " + nodes[i].getPriority()
);
}
Expand Down
1 change: 0 additions & 1 deletion __tests__/disconnect.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
TimeValue,
Origin,
Log,
LogLevel,
Action
} from "../src/core/internal";

Expand Down
4 changes: 2 additions & 2 deletions __tests__/mutations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ describe("Creating reactors at runtime", function () {
jest.setTimeout(5000);

it("Reactor with periodic timer", (done) => {
// Log.global.level = LogLevel.DEBUG
// Log.global.level = Log.LogLevel.DEBUG

const app = new Zeno(TimeValue.secs(4), done, () => {});

Expand All @@ -181,7 +181,7 @@ describe("Creating reactors at runtime", function () {
// jest.setTimeout(5000);

// it("Simple scatter gather", done => {
// Log.global.level = LogLevel.DEBUG
// Log.global.level = Log.LogLevel.DEBUG

// let app = new ScatterGather(TimeValue.secs(5), done, () => {})

Expand Down
5 changes: 2 additions & 3 deletions __tests__/reactors.errors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import {
InPort,
TimeUnit,
TimeValue,
Log,
LogLevel
Log
} from "../src/core/internal";

class R extends Reactor {
Expand Down Expand Up @@ -49,7 +48,7 @@ class R extends Reactor {
}

describe("Testing Error Cases", function () {
Log.global.level = LogLevel.DEBUG;
Log.setLevel(Log.LogLevel.DEBUG);

it("Multiple reactions for a callee port", () => {
var parent = new App();
Expand Down
11 changes: 5 additions & 6 deletions __tests__/reactors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
TimeValue,
Origin,
Log,
LogLevel,
Action
} from "../src/core/internal";

Expand Down Expand Up @@ -163,7 +162,7 @@ describe("Testing deadlines", function () {
jest.setTimeout(5000);

it("Missed reaction deadline on InPort", (done) => {
Log.global.level = LogLevel.WARN;
Log.setLevel(Log.LogLevel.WARN);

function fail() {
throw new Error("Test has failed.");
Expand All @@ -187,7 +186,7 @@ describe("Testing deadlines", function () {
it("Missed reaction deadline on the second reaction in the chain", (done) => {
// let consoleOutput: string[] = []

Log.global.level = LogLevel.WARN;
Log.setLevel(Log.LogLevel.WARN);

function fail() {
throw new Error("Test has failed.");
Expand Down Expand Up @@ -219,7 +218,7 @@ describe("Testing deadlines", function () {
});

it("Missed deadline with custom message", (done) => {
Log.global.level = LogLevel.WARN;
Log.setLevel(Log.LogLevel.WARN);

// let deadlineMissed:string = ""

Expand All @@ -233,7 +232,7 @@ describe("Testing deadlines", function () {
done,
fail,
() => {
Log.global.warn("Deadline missed!");
Log.warn(null, () => "Deadline missed!");
},
TimeValue.withUnits(1, TimeUnit.nsec)
);
Expand Down Expand Up @@ -274,7 +273,7 @@ describe("Testing Reactions", function () {

describe("Testing Actions", function () {
it("Mismatched logical time", () => {
Log.global.level = LogLevel.WARN;
Log.setLevel(Log.LogLevel.WARN);

function fail() {
throw new Error("Test has failed.");
Expand Down
2 changes: 1 addition & 1 deletion lingua-franca-ref.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
master
reactor-ts-remove-ulog
Loading