@@ -97,20 +97,23 @@ class ExamplePlugin implements Plugin {
9797 tableDefinitions : examplePluginTableDefinitions , // Use tableDefinitions
9898
9999 // Optional initialization function
100- onDatabaseInit : async ( db : AnyDatabase , schema : AnySchema ) => {
101- // Note: The function signature expects (db, schema) not (db, logger)
102- // We'll use console.log for now since logger is not available
103- console . log ( 'Initializing example plugin database...' ) ;
100+ onDatabaseInit : async ( db : AnyDatabase , schema : AnySchema , logger : FastifyBaseLogger ) => {
101+ logger . debug ( {
102+ operation : 'plugin_database_init' ,
103+ pluginId : 'example-plugin'
104+ } , 'Initializing example plugin database...' ) ;
104105
105106 // Use hardcoded plugin ID since 'this' is not available in arrow function
106107 const tableNameInSchema = `example-plugin_example_entities` ;
107108 const table = schema [ tableNameInSchema ] ;
108109
109110 if ( ! table ) {
110- console . error ( 'Critical: Table not found in global schema! Cannot initialize database for plugin.' , {
111+ logger . error ( {
112+ operation : 'plugin_database_init' ,
113+ pluginId : 'example-plugin' ,
111114 tableNameInSchema,
112115 availableTables : Object . keys ( schema )
113- } ) ;
116+ } , 'Critical: Table not found in global schema! Cannot initialize database for plugin.' ) ;
114117 return ;
115118 }
116119
@@ -130,7 +133,10 @@ class ExamplePlugin implements Plugin {
130133 }
131134
132135 if ( currentCount === 0 ) {
133- console . log ( 'Seeding initial data for example plugin...' ) ;
136+ logger . debug ( {
137+ operation : 'plugin_database_seed' ,
138+ pluginId : 'example-plugin'
139+ } , 'Seeding initial data for example plugin...' ) ;
134140 const dataToSeed = {
135141 id : 'example1' ,
136142 name : 'Example Entity' ,
@@ -142,7 +148,10 @@ class ExamplePlugin implements Plugin {
142148 // Assume NodePgDatabase-like behavior
143149 await ( db as NodePgDatabase ) . insert ( table as PgTable ) . values ( dataToSeed ) ;
144150 }
145- console . log ( 'Seeded initial data for example plugin' ) ;
151+ logger . info ( {
152+ operation : 'plugin_database_seed' ,
153+ pluginId : 'example-plugin'
154+ } , 'Seeded initial data for example plugin' ) ;
146155 }
147156 } ,
148157 } ;
0 commit comments