@@ -15,7 +15,7 @@ import {
1515 _PrintConfig ,
1616 Printer ,
1717} from './types'
18- import { getComponentName , print } from './utils'
18+ import { getComponentName , getRenderFunctionProps , print } from './utils'
1919import {
2020 ALLOWED_NODE_ENVS ,
2121 CSS_CHANGE ,
@@ -49,6 +49,7 @@ export function useLog({
4949 printer = console as Printer ,
5050 logLevel = DEFAULT_LOG_LEVEL ,
5151 groupLabelRenderer,
52+ render,
5253} : UseLogConfig = { } ) : UseLogReturn {
5354 const componentName = getComponentName ( )
5455
@@ -98,22 +99,30 @@ export function useLog({
9899 function logHooks ( ) : void {
99100 const isUnmounting = useRef ( false )
100101
102+ const printFunc = ( printProps : _PrintConfig < T > ) : void =>
103+ ( props ?. render ?? render ?? print ) (
104+ getRenderFunctionProps (
105+ printProps ,
106+ Boolean ( props ?. render ?? render ) ,
107+ ) ,
108+ )
109+
101110 useEffect ( function setIsUnmounting ( ) {
102111 return function setIsUnmountingOnMount ( ) {
103112 isUnmounting . current = true
104113 }
105114 } , [ ] )
106115
107116 useEffect ( function onMount ( ) {
108- print ( {
117+ printFunc ( {
109118 type : ComponentLifecycleLabels . Mount ,
110119 ...printProps ,
111120 } )
112121
113122 prevValueRef . current = value
114123
115124 return function onUnmount ( ) {
116- print ( {
125+ printFunc ( {
117126 type : ComponentLifecycleLabels . Unmount ,
118127 prevValue : prevValueRef . current ,
119128 ...printProps ,
@@ -123,7 +132,7 @@ export function useLog({
123132
124133 useEffect (
125134 function onChange ( ) {
126- print ( {
135+ printFunc ( {
127136 type : ComponentLifecycleLabels . Change ,
128137 prevValue : prevValueRef . current ,
129138 ...printProps ,
0 commit comments