@@ -124,31 +124,58 @@ class AdminForth implements IAdminForth {
124124 }
125125
126126 constructor ( config : AdminForthInputConfig ) {
127+ process . env . HEAVY_DEBUG && console . log ( '🔧 AdminForth constructor started' ) ;
128+
127129 if ( global . adminforth ) {
128130 throw new Error ( 'AdminForth instance already created in this process. ' +
129131 'If you want to use multiple instances, consider using different process for each instance' ) ;
130132 }
133+
134+ process . env . HEAVY_DEBUG && console . log ( '🔧 Creating CodeInjector...' ) ;
131135 this . codeInjector = new CodeInjector ( this ) ;
136+ process . env . HEAVY_DEBUG && console . log ( '🔧 CodeInjector created' ) ;
137+
138+ process . env . HEAVY_DEBUG && console . log ( '🔧 Creating ConfigValidator...' ) ;
132139 this . configValidator = new ConfigValidator ( this , config ) ;
140+ process . env . HEAVY_DEBUG && console . log ( '🔧 ConfigValidator created' ) ;
141+
142+ process . env . HEAVY_DEBUG && console . log ( '🔧 Creating AdminForthRestAPI...' ) ;
133143 this . restApi = new AdminForthRestAPI ( this ) ;
144+ process . env . HEAVY_DEBUG && console . log ( '🔧 AdminForthRestAPI created' ) ;
145+
146+ process . env . HEAVY_DEBUG && console . log ( '🔧 Creating SocketBroker...' ) ;
134147 this . websocket = new SocketBroker ( this ) ;
148+ process . env . HEAVY_DEBUG && console . log ( '🔧 SocketBroker created' ) ;
149+
135150 this . activatedPlugins = [ ] ;
136151
152+ process . env . HEAVY_DEBUG && console . log ( '🔧 Validating config...' ) ;
137153 this . configValidator . validateConfig ( ) ;
154+ process . env . HEAVY_DEBUG && console . log ( '🔧 Config validated' ) ;
155+
156+ process . env . HEAVY_DEBUG && console . log ( '🔧 Activating plugins...' ) ;
138157 this . activatePlugins ( ) ;
158+ process . env . HEAVY_DEBUG && console . log ( '🔧 Plugins activated' ) ;
139159
160+ process . env . HEAVY_DEBUG && console . log ( '🔧 Creating ExpressServer...' ) ;
140161 this . express = new ExpressServer ( this ) ;
162+ process . env . HEAVY_DEBUG && console . log ( '🔧 ExpressServer created' ) ;
163+
141164 // this.fastify = new FastifyServer(this);
165+ process . env . HEAVY_DEBUG && console . log ( '🔧 Creating AdminForthAuth...' ) ;
142166 this . auth = new AdminForthAuth ( this ) ;
167+ process . env . HEAVY_DEBUG && console . log ( '🔧 AdminForthAuth created' ) ;
168+
143169 this . connectors = { } ;
144170 this . statuses = {
145171 dbDiscover : 'running' ,
146172 } ;
147173
148-
149-
150174 console . log ( `${ this . formatAdminForth ( ) } v${ ADMINFORTH_VERSION } initializing...` ) ;
175+ process . env . HEAVY_DEBUG && console . log ( '🔧 About to set global.adminforth...' ) ;
151176 global . adminforth = this ;
177+ process . env . HEAVY_DEBUG && console . log ( '🔧 global.adminforth set successfully' ) ;
178+ process . env . HEAVY_DEBUG && console . log ( '🔧 AdminForth constructor completed' ) ;
152179 }
153180
154181 formatAdminForth ( ) {
@@ -174,14 +201,21 @@ class AdminForth implements IAdminForth {
174201 process . env . HEAVY_DEBUG && console . log ( '🔌🔌🔌 Activating plugins' ) ;
175202 const allPluginInstances = [ ] ;
176203 for ( let resource of this . config . resources ) {
204+ process . env . HEAVY_DEBUG && console . log ( `🔌 Checking plugins for resource: ${ resource . resourceId } ` ) ;
177205 for ( let pluginInstance of resource . plugins || [ ] ) {
206+ process . env . HEAVY_DEBUG && console . log ( `🔌 Found plugin: ${ pluginInstance . constructor . name } for resource ${ resource . resourceId } ` ) ;
178207 allPluginInstances . push ( { pi : pluginInstance , resource} ) ;
179208 }
180209 }
210+ process . env . HEAVY_DEBUG && console . log ( `🔌 Total plugins to activate: ${ allPluginInstances . length } ` ) ;
181211 allPluginInstances . sort ( ( { pi : a } , { pi : b } ) => a . activationOrder - b . activationOrder ) ;
212+
182213 allPluginInstances . forEach (
183- ( { pi : pluginInstance , resource} ) => {
214+ ( { pi : pluginInstance , resource} , index ) => {
215+ process . env . HEAVY_DEBUG && console . log ( `🔌 Activating plugin ${ index + 1 } /${ allPluginInstances . length } : ${ pluginInstance . constructor . name } for resource ${ resource . resourceId } ` ) ;
184216 pluginInstance . modifyResourceConfig ( this , resource ) ;
217+ process . env . HEAVY_DEBUG && console . log ( `🔌 Plugin ${ pluginInstance . constructor . name } modifyResourceConfig completed` ) ;
218+
185219 const plugin = this . activatedPlugins . find ( ( p ) => p . pluginInstanceId === pluginInstance . pluginInstanceId ) ;
186220 if ( plugin ) {
187221 process . env . HEAVY_DEBUG && console . log ( `Current plugin pluginInstance.pluginInstanceId ${ pluginInstance . pluginInstanceId } ` ) ;
@@ -190,8 +224,10 @@ class AdminForth implements IAdminForth {
190224 To support multiple plugin instance pre one resource, plugin should return unique string values for each installation from instanceUniqueRepresentation` ) ;
191225 }
192226 this . activatedPlugins . push ( pluginInstance ) ;
227+ process . env . HEAVY_DEBUG && console . log ( `🔌 Plugin ${ pluginInstance . constructor . name } activated successfully` ) ;
193228 }
194229 ) ;
230+ process . env . HEAVY_DEBUG && console . log ( '🔌 All plugins activation completed' ) ;
195231 }
196232
197233 getPluginsByClassName < T > ( className : string ) : T [ ] {
0 commit comments