Skip to content

Commit

Permalink
fix(logging): reduce warning level for routes not being found
Browse files Browse the repository at this point in the history
  • Loading branch information
sleidig committed Feb 16, 2024
1 parent aa04ec4 commit 189cd1c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe("RollCallComponent", () => {
participant2 = new Child("child2");
participant3 = new Child("child3");

mockLoggingService = jasmine.createSpyObj(["warn"]);
mockLoggingService = jasmine.createSpyObj(["warn", "debug"]);

TestBed.configureTestingModule({
imports: [
Expand Down Expand Up @@ -107,7 +107,7 @@ describe("RollCallComponent", () => {

expect(component.children).toEqual([participant1]);
expect(component.eventEntity.children).not.toContain(nonExistingChildId);
expect(mockLoggingService.warn).toHaveBeenCalled();
expect(mockLoggingService.debug).toHaveBeenCalled();
flush();
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ export class RollCallComponent implements OnChanges {
try {
child = await this.entityMapper.load(Child, childId);
} catch (e) {
this.loggingService.warn(
this.loggingService.debug(
"Could not find child " +
childId +
" for event " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe("NotFoundComponent", () => {
let mockLogging: jasmine.SpyObj<LoggingService>;

beforeEach(async () => {
mockLogging = jasmine.createSpyObj(LoggingService.name, ["warn"]);
mockLogging = jasmine.createSpyObj(LoggingService.name, ["debug"]);
await TestBed.configureTestingModule({
imports: [NotFoundComponent, RouterTestingModule],
providers: [
Expand All @@ -32,8 +32,8 @@ describe("NotFoundComponent", () => {
});

it("should call logging service with current route", () => {
expect(mockLogging.warn).toHaveBeenCalledWith(
"Could not find component for route: /some/path",
expect(mockLogging.debug).toHaveBeenCalledWith(
"Could not find route: /some/path",
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ export class NotFoundComponent implements OnInit {
) {}

ngOnInit() {
this.loggingService.warn(
"Could not find component for route: " + this.location.pathname,
);
if (!this.location.pathname.endsWith("/404")) {
this.loggingService.debug(
"Could not find route: " + this.location.pathname,
);
}
}
}

0 comments on commit 189cd1c

Please sign in to comment.