Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

lager for logging

  • Loading branch information...
commit 6c0d72d2db6010eecc6b3a44c78b849283a189db 1 parent bfbaaef
@tsloughter authored
View
3  .gitignore
@@ -1,2 +1,5 @@
+log
+console.log
+error.log
sys.config
_build
View
12 README.md
@@ -25,7 +25,17 @@ a # like [code]"#erlang"[code].
{mmmbot_images, [{access_key, <AWS KEY>},
{secret_key, <SECRET KEY>},
- {bucket, <S3 BUCKET>}]}
+ {bucket, <S3 BUCKET>}]},
+
+ {lager, [
+ {handlers, [
+ {lager_console_backend, info},
+ {lager_file_backend, [
+ {"error.log", error, 10485760, "$D0", 5},
+ {"console.log", info, 10485760, "$D0", 5}
+ ]}
+ ]}
+ ]}
].
```
View
2  lib/mmmbot/src/mmmbot.app.src
@@ -6,6 +6,6 @@
{modules, [mmmbot_app,
mmmbot_sup]},
{registered,[mmmbot_sup]},
- {applications, [kernel, stdlib]},
+ {applications, [kernel, stdlib, lager]},
{mod, {mmmbot_app,[]}},
{start_phases, []}]}.
View
4 lib/mmmbot/src/mmmbot.erl
@@ -112,7 +112,7 @@ handle_cast({message, Msg}, State=#state{sock=Sock, channel=Channel}) ->
%% @end
%%--------------------------------------------------------------------
handle_info({tcp, Sock, Data}, State) ->
- io:format("[~w] Received: ~s", [Sock, Data]),
+ lager:info("[~w] Received: ~s", [Sock, Data]),
parse_line(Sock, string:tokens(Data, ": "), Data, State),
{noreply, State}.
@@ -155,7 +155,7 @@ parse_line(Sock, [User, "PRIVMSG", Channel, Nickname | _], _Msg, #state{nickname
parse_line(_, [User, "PRIVMSG", _Channel | _], Msg, _State) ->
S1 = string:substr(Msg, string:rstr(Msg, " :")+2),
S2 = string:substr(S1, 1, length(S1)-2),
- io:format("Length: ~p, Message: ~p~n", [length(S1), S2]),
+ lager:info("Length: ~p, Message: ~p~n", [length(S1), S2]),
%% Notify all listners of the message
mmmbot_em:notify({S2, User});
View
2  lib/mmmbot_images/src/mmmbot_images.app.src
@@ -5,5 +5,5 @@
{vsn, "0.1.0"},
{modules, []},
{registered,[]},
- {applications, [kernel, stdlib, ibrowse, erlcloud, mmmbot]},
+ {applications, [kernel, stdlib, ibrowse, erlcloud, mmmbot, lager]},
{start_phases, []}]}.
View
8 lib/mmmbot_images/src/mmmbot_images.erl
@@ -139,15 +139,15 @@ parse(_Bucket, _Msg) ->
-spec add_url(string(), string(), boolean()) -> ok.
add_url(Bucket, URL, IsSSL) ->
- io:format("Checking if image ~p:~p~n", [length(URL), URL]),
+ lager:info("Checking if image ~p:~p~n", [length(URL), URL]),
ExtStr = string:substr(URL, string:rchr(URL, $.)),
case is_image_ext(ExtStr) of
true ->
- io:format("Is image~n"),
+ lager:info("Is image~n"),
image_to_s3(Bucket, URL, ExtStr, IsSSL),
ok;
_ ->
- io:format("Not an image~n"),
+ lager:info("Not an image~n"),
ok
end.
@@ -160,7 +160,7 @@ image_to_s3(Bucket, URL, ExtStr, IsSSL) ->
-spec is_image_ext(string()) -> boolean().
% Compares to standard message extensions
is_image_ext(ExtStr) ->
- io:format("Checking string: ~p~n", [ExtStr]),
+ lager:info("Checking string: ~p~n", [ExtStr]),
lists:member(ExtStr, [".jpg", ".JPG", ".png", ".PNG", ".gif", ".GIF",
".jpeg", ".JPEG", ".xmp", ".XMP", ".tiff", ".TIFF"]).
View
1  sinan.config
@@ -9,3 +9,4 @@
{include_erts, true}.
+{compile_args, [{parse_transform, lager_transform}]}.
Please sign in to comment.
Something went wrong with that request. Please try again.