diff --git a/invokeai/frontend/web/src/app/store/middleware/debugLoggerMiddleware.ts b/invokeai/frontend/web/src/app/store/middleware/debugLoggerMiddleware.ts index 89010275d19..c112f2dd97d 100644 --- a/invokeai/frontend/web/src/app/store/middleware/debugLoggerMiddleware.ts +++ b/invokeai/frontend/web/src/app/store/middleware/debugLoggerMiddleware.ts @@ -7,12 +7,20 @@ import { diff } from 'jsondiffpatch'; /** * Super simple logger middleware. Useful for debugging when the redux devtools are awkward. */ -export const debugLoggerMiddleware: Middleware = (api: MiddlewareAPI) => (next) => (action) => { - const originalState = api.getState(); - console.log('REDUX: dispatching', action); - const result = next(action); - const nextState = api.getState(); - console.log('REDUX: next state', nextState); - console.log('REDUX: diff', diff(originalState, nextState)); - return result; -}; +export const getDebugLoggerMiddleware = + (options?: { withDiff?: boolean; withNextState?: boolean }): Middleware => + (api: MiddlewareAPI) => + (next) => + (action) => { + const originalState = api.getState(); + console.log('REDUX: dispatching', action); + const result = next(action); + const nextState = api.getState(); + if (options?.withNextState) { + console.log('REDUX: next state', nextState); + } + if (options?.withDiff) { + console.log('REDUX: diff', diff(originalState, nextState)); + } + return result; + };