This commit is contained in:
Craig Everett 2017-12-18 13:29:06 +09:00
parent c47a88c319
commit 83a7a68844
3 changed files with 95 additions and 0 deletions

34
include/zx_logger.hrl Normal file
View File

@ -0,0 +1,34 @@
-export([log/2, log/3]).
-spec log(Level, Format) -> ok
when Level :: info
| warning
| error,
Format :: string().
%% @private
%% @equiv log(Level, Format, [])
log(Level, Format) ->
log(Level, Format, []).
-spec log(Level, Format, Args) -> ok
when Level :: info
| warning
| error,
Format :: string(),
Args :: [term()].
%% @private
%% A logging abstraction to hide whatever logging back end is actually in use.
%% Format must adhere to Erlang format string rules, and the arity of Args must match
%% the provided format.
log(Level, Format, Args) ->
Tag =
case Level of
info -> "[INFO]";
warning -> "[WARNING]";
error -> "[ERROR]"
end,
io:format("~s ~p: " ++ Format ++ "~n", [Tag, self() | Args]).

48
zmake Executable file
View File

@ -0,0 +1,48 @@
#! /usr/bin/env escript
-mode(compile).
main(Args) ->
ok = make(),
ok = lists:foreach(fun dispatch/1, Args),
halt(0).
dispatch("edoc") ->
ok = edoc();
dispatch("dialyze") ->
ok = dialyze();
dispatch("test") ->
ok = test();
dispatch(Unknown) ->
ok = io:format("zmake: Unknown directive: ~tp~n", [Unknown]),
halt(1).
make() ->
true = code:add_patha("ebin"),
up_to_date = make:all(),
halt(0).
edoc() ->
ok = io:format("EDOC: Writing docs...~n"),
ok = edoc:application(zomp, ".", []),
halt(0).
dialyze() ->
ok =
case dialyzer:run([{from, src_code}, {files_rec, ["./src"]}]) of
[] ->
io:format("Dialyzer found no errors and returned no warnings! Yay!~n");
Warnings ->
Messages = [dialyzer:format_warning(W) || W <- Warnings],
lists:foreach(fun io:format/1, Messages)
end,
halt(0).
test() ->
ok = io:format("TEST: If I only had a brain.~n"),
halt(0).

13
zx.bash Executable file
View File

@ -0,0 +1,13 @@
#! /bin/bash
# set -x
ZOMP_DIR="$HOME/.zomp"
ORIGIN="$(pwd)"
VERSION="$(ls $ZOMP_DIR/lib/otpr-zx/ | sort --field-separator=. --reverse | head --lines=1)"
ZX_DIR="$ZOMP_DIR/lib/otpr-zx/$VERSION"
cd "$ZX_DIR"
./zmake
cd "$ZOMP_DIR"
erl -pa "$ZX_DIR/ebin" -run zx start $@