Add logger to viewport grid

This commit is contained in:
igoroctaviano 2021-03-04 09:28:32 -03:00
parent df8c4db2ed
commit 8581405352
2 changed files with 6 additions and 5 deletions

View File

@ -60,7 +60,7 @@ const LoggerProvider = ({ children, service }) => {
};
/**
* Sets the implementation of a log service that can be used by extensions.
* Sets the implementation of a log service that can be used by extensions
*
* @returns void
*/
@ -74,7 +74,7 @@ const LoggerProvider = ({ children, service }) => {
};
/**
* Higher Order Component to use the log methods through a Class Component.
* Higher Order Component to use the log methods through a Class Component
*
* @returns
*/

View File

@ -4,7 +4,7 @@ import React, { useEffect } from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import { utils } from '@ohif/core';
import { useSnackbarContext } from '@ohif/ui';
import { useSnackbarContext, useLogger } from '@ohif/ui';
//
import ViewportPane from './ViewportPane.js';
import DefaultViewport from './DefaultViewport.js';
@ -12,7 +12,7 @@ import EmptyViewport from './EmptyViewport.js';
const { loadAndCacheDerivedDisplaySets } = utils;
const ViewportGrid = function (props) {
const ViewportGrid = function(props) {
const {
activeViewportIndex,
availablePlugins,
@ -36,14 +36,15 @@ const ViewportGrid = function (props) {
}
const snackbar = useSnackbarContext();
const logger = useLogger();
useEffect(() => {
if (isStudyLoaded) {
viewportData.forEach(displaySet => {
const promises = loadAndCacheDerivedDisplaySets(displaySet, studies);
promises.forEach(promise => {
promise.catch(error => {
logger.error({ error, message: error.message });
snackbar.show({
title: 'Error loading derived display set:',
message: error.message,