Fork me on GitHub

Hi there - I have been trying to figure something out and thought I would drop in here to see if anyone had some advice. I have a component, Config, which pulls in configuration from disk and makes it available to several other components. I'd like to use that configuration at system startup to setup logging levels, probably within it's own Logging component so it can cleanly access the config dependency. I'm wondering whether there is a nicer way to have that logging component run early, beyond making it a dependency of all other components - something i'd rather not do as they don't really depend on it


The other option I was considering was swapping out the current use of SystemMap for a custom component that first starts config, then starts the logging, then starts the remainder of the system


(right now I'm just calling a setup-logging function from my config component, but I am feeling like there is a better way to keep the two separate


I'd probably setup logging outside of system-related code. It doesn't even have to be encapsulated in Logging component because there's no start/stop logic needed:

(defn example-system [config-options]
  ; .......... setup logging ..........
  (let [{:keys [host port]} config-options]
      :db (new-database host port)
      :scheduler (new-scheduler)
      :app (component/using
             (example-component config-options)
             {:database  :db
              :scheduler :scheduler}))))


the problem is I need to run that logging setup prior to those other components starting up - by default, some of them are rather spammy in their logging output


would be a problem if logging is set up when example-system function is called?


it will ensure the order you need


Well, my config is pulled in via a component. it gets slurped off the filesystem, some minor transformations, and then made availble to other components as a dependency


so I need the config component to have been started in order to feed to the logging setup


ah, right, hm.. in my app the config is pulled explicitly in main function and is then passed as an arg into example-system-like function


I was poking through component code and I think the most straightforward is going to be a custom System component so I can hardcode that initial initialization order. but for now i'll just slap a function call in my Config component