Skip to content

Instantly share code, notes, and snippets.

@jfreeze
Created September 26, 2014 14:33
Show Gist options
  • Save jfreeze/7472e0f0ccc40e8314c4 to your computer and use it in GitHub Desktop.
Save jfreeze/7472e0f0ccc40e8314c4 to your computer and use it in GitHub Desktop.
Distro.DistroCalc logging
defmodule Distro.DistroCalc do
use GenServer
require Logger
def start_link do
GenServer.start_link(__MODULE__, [], name: {:global, __MODULE__})
end
def add(x,y) do
Logger.info "self: #{inspect Node.self}"
GenServer.call({:global, __MODULE__}, {:cal, x, y})
end
def handle_call({:cal, x, y}, _from, state) do
Logger.info "self: #{inspect self}, Node.self: #{inspect Node.self}, from: #{inspect _from}, state: #{inspect state}"
{ :reply, x + y, state }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment