How do I get the environment name when using environ in Clojure? I mean, :dev, :test, etc. The reason for wanting this is to pass it to Yeller so when it displays errors it can tell me which environment they happened into. Errors in staging are treated differently than errors in production.
Environ only provides access to environment variables, you need to set them yourself. You can use lein-environ
to set environment variables in your project.clj
in different profiles. These profiles will be picked by leiningen and merged together, which you can then access from your code. For example, we have:
:profiles {:dev {:resource-paths ["test-resources"]
:env {:environment "development"
:db-host "localhost"
:port 5000}}}
In production we provide actual environment variables instead.