Exconf v0.2.0 Exconfig View Source
The module Exconfig provides the API for the Exconfig-package.
This is
get/0
... get all cached settingsget/3
... get a specific entry (read if not cached) [macro]- and
clear_cache!/0
... remove all entries from the cache
All usage of Exconfig.get
will be captured and written to
configuration.log
at termination.
Configuration
config :exconfig, config_log_file: "configuration.log"
When you compile your application for any evnironment but prod
,
the macro will record the usage of it. In production environment
this doesn't happen and using the macro is a straight forward call
to Exconfig._get(env, key, default)
configuration.log
configuration.log
can be used as a template for creating your setup.env
file.
Link to this section Summary
Functions
Get a value from cache or load it if not cached yet.
Remove all entries from the cache, so they will be re-read if accessed again.
Get the entire loaded cache.
The macro records the usage of get
with the Exconfig.ConfigLogger
module
and then reads the configuration as usual.
Link to this section Functions
_get(application_key, key, default \\ nil) View Source
Get a value from cache or load it if not cached yet.
Examples
Return the default if key is not found anywhere
iex> Exconfig.get(:exconfig, :unknown_config_key, :not_found)
:not_found
Return from a value configured in config/*
iex> Exconfig.get(:logger, :level, :error)
:debug
Return a value provided as a system environment var
The given key will be converted to a string, if it is an :atom
.
Also, it will be uppercased.
iex> System.put_env("ELIXIRRULEZ", "true")
iex> Exconfig.get(:exconfig, :elixirrulez, :not_found)
"true"
clear_cache!() View Source
Remove all entries from the cache, so they will be re-read if accessed again.
Get the entire loaded cache.
Examples
iex> Exconfig.get()
%{}
get(env, key, default \\ nil) View Source (macro)
The macro records the usage of get
with the Exconfig.ConfigLogger
module
and then reads the configuration as usual.