diff --git a/README.md b/README.md index c85dfe1..a7c088d 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ A minimal callback module could look like this: -module(elli_minimal_callback). -export([handle/2, handle_event/3]). --include_lib("elli/include/elli.hrl"). +-include_lib("elli/include/eWSrv.hrl"). -behaviour(elli_handler). handle(Req, _Args) -> diff --git a/include/elli.hrl b/include/eWSrv.hrl similarity index 100% rename from include/elli.hrl rename to include/eWSrv.hrl diff --git a/src/wsSrv/elli_util.hrl b/include/wsCom.hrl similarity index 61% rename from src/wsSrv/elli_util.hrl rename to include/wsCom.hrl index 204fbfc..7ac5b56 100644 --- a/src/wsSrv/elli_util.hrl +++ b/include/wsCom.hrl @@ -1,6 +1,8 @@ --ifdef(OTP_RELEASE). --include_lib("kernel/include/logger.hrl"). --else. +-define(wsErr(Format, Args), error_logger:error_msg(Format, Args)). +-define(wsWarn(Format, Args), error_logger:warning_msg(Format, Args)). +-define(wsInfo(Format, Args), error_logger:info_msg(Format, Args)). +-define(wsGLV(Key, List, Default), elli_util:getLValue(Key, List, Default)). + -define(LOG_ERROR(Str), error_logger:error_msg(Str)). -define(LOG_ERROR(Format, Data), error_logger:error_msg(Format, Data)). -define(LOG_INFO(Format, Data), error_logger:info_msg(Format, Data)). diff --git a/src/test/elli_tests.erl b/src/test/elli_tests.erl index ab34a9b..17909db 100644 --- a/src/test/elli_tests.erl +++ b/src/test/elli_tests.erl @@ -1,6 +1,6 @@ -module(elli_tests). -include_lib("eunit/include/eunit.hrl"). --include("elli.hrl"). +-include("eWSrv.hrl"). -include("elli_test.hrl"). -define(README, "README.md"). diff --git a/src/wsSrv/elli.erl b/src/wsSrv/elli.erl index 8f7630f..8028b44 100644 --- a/src/wsSrv/elli.erl +++ b/src/wsSrv/elli.erl @@ -1,13 +1,7 @@ -%% @doc: Elli acceptor manager -%% -%% This gen_server owns the listen socket and manages the processes -%% accepting on that socket. When a process waiting for accept gets a -%% request, it notifies this gen_server so we can start up another -%% acceptor. -%% -module(elli). -behaviour(gen_server). --include("elli.hrl"). + +-include("eWSrv.hrl"). -include("elli_util.hrl"). %% API diff --git a/src/wsSrv/elli_example_callback.erl b/src/wsSrv/elli_example_callback.erl index f977ca6..c11833c 100644 --- a/src/wsSrv/elli_example_callback.erl +++ b/src/wsSrv/elli_example_callback.erl @@ -10,7 +10,7 @@ -export([handle/2, handle_event/3]). -export([chunk_loop/1]). --include("elli.hrl"). +-include("eWSrv.hrl"). -include("elli_util.hrl"). -behaviour(elli_handler). diff --git a/src/wsSrv/elli_http.erl b/src/wsSrv/elli_http.erl index e2a746f..f2a13bf 100644 --- a/src/wsSrv/elli_http.erl +++ b/src/wsSrv/elli_http.erl @@ -4,8 +4,8 @@ %% connects. It then handles requests on that connection until it's %% closed either by the client timing out or explicitly by the user. -module(elli_http). --include("elli.hrl"). --include("elli_util.hrl"). +-include("eWSrv.hrl"). +-include("wsCom.hrl"). %% API diff --git a/src/wsSrv/elli_request.erl b/src/wsSrv/elli_request.erl index 4b6ecd7..e28aac5 100644 --- a/src/wsSrv/elli_request.erl +++ b/src/wsSrv/elli_request.erl @@ -1,5 +1,5 @@ -module(elli_request). --include("elli.hrl"). +-include("eWSrv.hrl"). -include("elli_util.hrl"). -export([send_chunk/2 diff --git a/src/wsSrv/elli_test.erl b/src/wsSrv/elli_test.erl index 51ae107..550aa3c 100644 --- a/src/wsSrv/elli_test.erl +++ b/src/wsSrv/elli_test.erl @@ -8,7 +8,7 @@ -module(elli_test). --include("elli.hrl"). +-include("eWSrv.hrl"). -export([call/5]). diff --git a/src/wsSrv/elli_util.erl b/src/wsSrv/elli_util.erl index 6875dd4..43a9f07 100644 --- a/src/wsSrv/elli_util.erl +++ b/src/wsSrv/elli_util.erl @@ -1,6 +1,6 @@ -module(elli_util). --include("elli.hrl"). --include("elli_util.hrl"). +-include("eWSrv.hrl"). +-include("wsCom.hrl"). -include_lib("kernel/include/file.hrl"). @@ -69,3 +69,11 @@ file_size(Filename) -> {error, Reason} -> {error, Reason}; _ -> {error, invalid_file} end. + +getLValue(Key, List, Default) -> + case lists:keyfind(Key, 1, List) of + false -> + Default; + {Key, Value} -> + Value + end.