Current section
Files
Jump to
Current section
Files
src/filezcache_event_logger.erl
%% @author Marc Worrell
%% @copyright 2013-2014 Marc Worrell
%% Copyright 2013-2014 Marc Worrell
%%
%% Licensed under the Apache License, Version 2.0 (the "License");
%% you may not use this file except in compliance with the License.
%% You may obtain a copy of the License at
%%
%% http://www.apache.org/licenses/LICENSE-2.0
%%
%% Unless required by applicable law or agreed to in writing, software
%% distributed under the License is distributed on an "AS IS" BASIS,
%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
%% See the License for the specific language governing permissions and
%% limitations under the License.
-module(filezcache_event_logger).
-behaviour(gen_event).
-export([add_handler/0, delete_handler/0]).
-export([init/1, handle_event/2, handle_call/2, handle_info/2, code_change/3, terminate/2]).
-record(state, {}).
%% API
add_handler() ->
filezcache_event:add_handler(?MODULE, []).
delete_handler() ->
filezcache_event:delete_handler(?MODULE, []).
%% gen_event callbacks
init([]) ->
{ok, #state{}}.
handle_event({insert, Key}, State) ->
error_logger:info_msg("insert(~p)~n", [Key]),
{ok, State};
handle_event({lookup, Key}, State) ->
error_logger:info_msg("lookup(~p)~n", [Key]),
{ok, State};
handle_event({delete, Key}, State) ->
error_logger:info_msg("delete(~p)~n", [Key]),
{ok, State};
handle_event({insert_ready, {Key, Size, Filename}}, State) ->
error_logger:info_msg("insert_ready(~p, ~p, ~p)~n", [Key, Size, Filename]),
{ok, State}.
handle_call(_Request, State) ->
Reply = ok,
{ok, Reply, State}.
handle_info(_Info, State) ->
{ok, State}.
terminate(_Reason, _State) ->
ok.
code_change(_OldVsn, State, _Extra) ->
{ok, State}.