1
- import React from 'react'
1
+ import React , { useEffect } from 'react'
2
2
import type { Meta , StoryObj } from '@storybook/react'
3
+ import { createConsoleTraceLogger } from '../../v3/ConsoleTraceLogger'
3
4
import { TraceManagerDebugger } from '../../v3/TraceManagerDebugger'
4
5
import { App } from './App'
5
6
import { traceManager } from './traceManager'
@@ -19,10 +20,10 @@ export const Primary: Story = {
19
20
export const WithDebugger : Story = {
20
21
render : ( ) => (
21
22
< div >
22
- < App />
23
- < div style = { { marginTop : '20px' } } >
23
+ < div style = { { marginBottom : '20px' } } >
24
24
< TraceManagerDebugger traceManager = { traceManager } />
25
25
</ div >
26
+ < App />
26
27
</ div >
27
28
) ,
28
29
}
@@ -35,3 +36,37 @@ export const WithFloatingDebugger: Story = {
35
36
</ div >
36
37
) ,
37
38
}
39
+
40
+ export const WithConsoleTraceLogger : Story = {
41
+ render : ( ) => {
42
+ // Initialize the console trace logger when the story renders
43
+ useEffect ( ( ) => {
44
+ const consoleLogger = createConsoleTraceLogger ( traceManager , {
45
+ verbose : true ,
46
+ } )
47
+
48
+ // Log a message to explain how to use the console
49
+ console . info (
50
+ 'ConsoleTraceLogger is active. Open your browser console to see trace events. ' +
51
+ 'Try clicking on tickets to see trace events logged in real-time.' ,
52
+ )
53
+
54
+ // Example of custom logger function if needed
55
+ // consoleLogger.setOptions({
56
+ // logFn: (message) => {
57
+ // console.log(`%c${message}`, 'color: blue');
58
+ // }
59
+ // });
60
+
61
+ // Clean up the logger when the component unmounts
62
+ return ( ) => {
63
+ consoleLogger . cleanup ( )
64
+ console . info (
65
+ 'ConsoleTraceLogger has been cleaned up and unsubscribed from all events.' ,
66
+ )
67
+ }
68
+ } , [ ] )
69
+
70
+ return < App />
71
+ } ,
72
+ }
0 commit comments