Skip to content

Instantly share code, notes, and snippets.

@sunaku
Created October 21, 2015 22:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sunaku/6a043d726b46a9bfaeb3 to your computer and use it in GitHub Desktop.
Save sunaku/6a043d726b46a9bfaeb3 to your computer and use it in GitHub Desktop.
Elixir's Logger to stderr
$ mix new foo
* creating README.md
* creating .gitignore
* creating mix.exs
* creating config
* creating config/config.exs
* creating lib
* creating lib/foo.ex
* creating test
* creating test/test_helper.exs
* creating test/foo_test.exs
Your mix project was created successfully.
You can use mix to compile it, test it, and more:
cd foo
mix test
Run `mix help` for more commands.
$ cd foo
$ mix test
Compiled lib/foo.ex
Generated foo app
.
Finished in 0.07 seconds (0.07s on load, 0.00s on tests)
1 test, 0 failures
Randomized with seed 470405
$ mix run -e 'require Logger; Logger.info "hello"'
15:39:45.130 [info] hello
$ mix run -e 'require Logger; GenEvent.add_handler(Logger, {Logger.Backends.Console, :stderr}, {:stderr, []}); Logger.info "hello"'
15:39:49.954 [info] hello
15:39:49.954 [info] hello
$ mix run -e 'require Logger; GenEvent.add_handler(Logger, {Logger.Backends.Console, :stderr}, {:stderr, []}); Logger.info "hello"' 2>/dev/null
15:39:53.835 [info] hello
15:39:53.835 [info] hello
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment