Skip to content

Commit

Permalink
feature(config): add env-based config
Browse files Browse the repository at this point in the history
  • Loading branch information
ckoch-cars committed Aug 14, 2022
1 parent b6541cf commit 2a17d00
Show file tree
Hide file tree
Showing 4 changed files with 818 additions and 18 deletions.
5 changes: 5 additions & 0 deletions config/config.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import Config

if File.exists?(Path.join([__DIR__, "#{config_env()}.exs"])) do
import_config "#{config_env()}.exs"
end
4 changes: 4 additions & 0 deletions config/test.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import Config

config :ex_factor, ExFactor.Callers,
trace_function: &ExFactor.Support.Trace.trace_function/0
20 changes: 2 additions & 18 deletions mix.exs
Original file line number Diff line number Diff line change
@@ -1,23 +1,7 @@
defmodule ExFactor.Tracer do
@trace_types ~w(import imported_function alias alias_expansion alias_reference require struct_expansion remote_function local_function)a
def trace({type, meta, module, name, arity}, env) when type in @trace_types do
ExFactor.Server.record(type, env.file, meta[:line], meta[:column], module, name, arity, env.context_modules, env.module)
# content = """
# ExFactor.Tracer mix.exs
# type: #{type}
# meta: #{inspect(meta)}
# traced_module: #{module}
# name: #{name}
# arity: #{inspect(arity)}
# filepath: #{env.file}
# context_modules: #{inspect(env.context_modules)}
# caller_module: #{env.module}

# """
# File.mkdir_p!("./tmp")
# File.touch!("./tmp/traces")
# File.write!("./tmp/traces", content, [:append])
:ok
ExFactor.Server.record(type, env.file, meta[:line], meta[:column], module, name, arity, env.module)
end

def trace(_event, _env) do
Expand All @@ -39,7 +23,7 @@ defmodule ExFactor.MixProject do
version: @version,
elixir: "~> 1.13",
elixirc_paths: elixirc_paths(Mix.env()),
start_permanent: Mix.env() == :prod,
config_path: "./config/config.exs",
deps: deps(),
description: description(),
docs: docs(),
Expand Down
Loading

0 comments on commit 2a17d00

Please sign in to comment.