onkel-dirtus / logger_file_backend

MIT License
307 stars 128 forks source link

Use application specific configuration keys #37

Open DavidAntaramian opened 7 years ago

DavidAntaramian commented 7 years ago

I was responding to a question someone had about this package, and I noticed that you're using the :logger application configuration to hold configuration specific to this package.

You should instead be using your application's own configuration space, in this case :logger_file_backend, e.g.:

config :logger_file_backend, :error_log,
  path: "/var/log/my_app/error.log"
xurde commented 7 years ago

@DavidAntaramian I think this is due to the fact that LoggerFileBackend is a backend for the Logger module instead of a standalone package which works autonomously.

DavidAntaramian commented 7 years ago

@xurde That's not the way configuration keys work, though. :logger_file_backend is a distinct OTP application and should source all of its configuration from the :logger_file_backend key in the configuration . :logger is its own OTP application that maintains its own set of configuration keys.

ngeraedts commented 6 years ago

:logger_file_backend is not a distinct OTP application. It's a backend for the :logger OTP application which spawns multiple processes for each configured backend. It's entirely possible you will end up with a configuration like the following:

config :logger,
  backends: [{LoggerFileBackend, :file_log}, :console]

config :logger, :file_log,
  path: "/var/log/my_otp_app.log",
  level: :info

config :logger, :console, 
  level: warn
isaacsanders commented 6 years ago

This issue feels closed. @ngeraedts's statement seems to settle things. If this were an application, it might be different, but as it stands, the public API is a module used by the logger application. Unless the logger changes its approach to backends, it doesn't look like there is a case.

DavidAntaramian commented 6 years ago

@isaacsanders @ngeraedts's statement is fundamentally flawed. :logger_file_backend is a distinct OTP application. There would be no possible way for it not to be a distinct OTP application. This is why there is an :app key and application/0 function in the mix.exs file. That is why a .app file is generated during the build process when the project is compiled. That is how the Erlang runtime system loads the project's compiled modules into the VM.

isaacsanders commented 6 years ago

@DavidAntaramian Sure. It still feels weird to configure it separately, but that is a different argument.