Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

modified: Makefile

	modified:   ebin/log4erl.app
	modified:   include/log4erl.hrl
	modified:   priv/log4erl.conf
	modified:   src/Makefile
	modified:   src/file_appender.erl
	modified:   src/log4erl.erl
	modified:   src/log4erl_conf.erl
	modified:   src/log4erl_lex.erl
	modified:   src/log4erl_lex.xrl
	modified:   src/log4erl_parser.erl
	modified:   src/log4erl_parser.yrl
	modified:   src/log4erl_sup.erl
	new file:   src/log_filter.erl
	new file:   src/log_filter_codegen.erl
	modified:   src/log_manager.erl
	modified:   src/syslog_appender.erl
  • Loading branch information...
commit 8051eb0fe47c1a2e2e525afeb56a4ea6475719ce 1 parent fe1ced6
@ahmednawras ahmednawras authored
View
2  Makefile
@@ -12,6 +12,6 @@ clean:
rm -f src/*~
rm -f ebin/*~
rm -f include/*~
-# cd dir1; make clean
+ cd ${SRC}; make clean
#install:
# cp -f ebin/* ../../www/ebin
View
4 ebin/log4erl.app
@@ -2,10 +2,10 @@
%% application.
{application, log4erl,
[{description, "Logger for erlang in the spirit of Log4J"},
- {vsn, "0.8.6"},
+ {vsn, "0.9.0"},
{modules, [log4erl]},
{registered,[log4erl]},
{applications, [kernel,stdlib]},
- {mod, {log4erl,[default_logger]}},
+ {mod, {log4erl,[]}},
{start_phases, []}
]}.
View
2  include/log4erl.hrl
@@ -12,7 +12,7 @@
-define(FILE_OPTIONS,[write, raw, binary, append]).
-define(FILE_OPTIONS_ROTATE,[write, raw, binary]).
-%%-define(DEBUG, true).
+%-define(DEBUG, true).
-ifdef(DEBUG).
-define(LOG(X), io:format("~p: " ++ X,[?MODULE])).
View
2  priv/log4erl.conf
@@ -1,3 +1,5 @@
+cutoff_level = warn
+
%% Default logger
%% it includes a file appender and a console appender
logger{
View
27 src/Makefile
@@ -2,7 +2,7 @@ EBIN_DIR=../ebin
INCLUDE_DIR=../include
ERLS=$(wildcard *.erl)
ERLC=erlc -o $(EBIN_DIR) -I ${INCLUDE_DIR}
-BEAMS=$(ERLS:.erl=.beam)
+BEAMS=$(ERLS:%.erl=$(EBIN_DIR)/%.beam)
# leave these lines alone
.SUFFIXES: .erl .beam .yrl
@@ -13,23 +13,22 @@ BEAMS=$(ERLS:.erl=.beam)
#.yrl.erl:
# $(ERLC)-W $<
+all: compile
-# Here's a list of the erlang modules you want compiling
-# If the modules don't fit onto one line add a \ character
-# to the end of the line and continue on the next line
-# Edit the lines below
-#MODS = log4erl_sup log4erl file_appender console_appender log_manager logger_guard log4erl_utils dummy_appender log_formatter smtp_fsm.erl email_msg.erl
-#MODS = $(ERLS)
-BEAMS = $(ERLS:.erl=.beam)
-MODS = $(BEAMS:.beam=)
-
-all: compile
-
-%.beam: %.erl
+$(EBIN_DIR)/%.beam: %.erl
@echo ">>" compiling: $<
@$(ERLC) $<
-compile: ${MODS:%=%.beam}
+generate_parser:
+ @echo ">>" generating log4erl_parser.erl from log4erl_parser.yrl $<
+ erlc log4erl_parser.yrl
+
+# export LEEX_PATH env var for this to work
+generate_lex:
+ @echo ">>" generating log4erl_lex.erl from log4erl_lex.xrl $<
+ erl -noinput -noshell -pa $$LEEX_PATH/ebin -s leex file log4erl_lex.xrl -s init stop
+
+compile: ${BEAMS}
clean:
rm -rf ../ebin/*.beam erl_crash.dump
View
53 src/file_appender.erl
@@ -79,9 +79,9 @@ handle_event({change_level, Level}, State) ->
{ok, State2};
handle_event({log,LLog}, State) ->
?LOG2("handl_event:log = ~p~n",[LLog]),
- do_log(LLog, State),
- Res = check_rotation(State),
- {ok, Res}.
+ ResState = check_rotation(State),
+ do_log(LLog, ResState),
+ {ok, ResState}.
handle_call({change_format, Format}, State) ->
@@ -145,6 +145,38 @@ rotate(#file_appender{fd = Fd, dir=Dir, file_name=Fn, counter=Cntr, rotation=Ro
State2 = #file_appender{dir = Dir, file_name = Fn, fd = Fd2, counter=C, log_type = Ltype, rotation = Rot, suffix=Suf, level=Level, format=Format},
{ok, State2}.
+rotate_daily(#file_appender{fd = Fd, dir=Dir, file_name=Fn, counter=Cntr, rotation=Rot, suffix=Suf, log_type=Ltype, level=Level, format=Format} = _S, {Year, Month, Day}) ->
+ file:close(Fd),
+ ?LOG("Starting daily rotation~n"),
+ Date = lists:flatten(io_lib:format("~4.10.0B-~2.10.0B-~2.10.0B", [Year, Month, Day])),
+ Folder = Dir ++ "/" ++ Fn ++ "." ++ lists:flatten(io_lib:format("~4.10.0B-~2.10.0B", [Year, Month])),
+ Src = Dir ++ "/" ++ Fn ++ "." ++ Suf,
+ Fname = Folder ++ "/" ++ Fn ++ "." ++ Date ++ "." ++ Suf,
+ ?LOG2("Moving file from ~p to ~p~n", [Src, Fname]),
+
+ % each month has it's own log dir
+ file:make_dir(Folder),
+ file:rename(Src, Fname),
+
+ case erlang:date() of
+ {Year, Month, _} -> ok;
+ _ ->
+ % compress to zip and remove all previous month log files
+ RemoveOld = fun() ->
+ {ok, _} = zip:create(Folder ++ ".zip", [Folder]),
+ {ok, Files} = file:list_dir(Folder),
+ lists:foreach(fun(F) -> file:delete(Folder ++ "/" ++ F) end, Files),
+ file:del_dir(Folder)
+ end,
+ spawn(RemoveOld)
+ end,
+
+ {ok, Fd2} = file:open(Src, ?FILE_OPTIONS_ROTATE),
+ State2 = #file_appender{dir = Dir, file_name = Fn, fd = Fd2, counter=Cntr, log_type = Ltype, rotation = Rot, suffix=Suf, level=Level, format=Format},
+ {ok, State2}.
+
+
+
% Check if the file needs to be rotated
% ignore in case of if log type is set to time instead of size
check_rotation(State) ->
@@ -161,8 +193,19 @@ check_rotation(State) ->
true ->
State
end;
- %% time-based rotation is not implemented yet
+
+ daily ->
+ File = Dir ++ "/" ++ Fname ++ "." ++ Suf,
+ {ok, Finfo} = file:read_file_info(File),
+ {CDate, _CTime} = Finfo#file_info.ctime,
+ case erlang:date() of
+ CDate ->
+ State;
+ _ ->
+ {ok, State2} = rotate_daily(State, CDate),
+ State2
+ end;
+
_ ->
State
end.
-
View
156 src/log4erl.erl
@@ -3,14 +3,11 @@
-author("Ahmed Al-Issaei").
-license("MPL-1.1").
--behaviour(gen_server).
-behaviour(application).
-include("../include/log4erl.hrl").
%% API
--export([start_link/1]).
-
-export([change_log_level/1, change_log_level/2]).
-export([change_level/2, change_level/3]).
-export([add_logger/1, conf/1]).
@@ -33,66 +30,69 @@
-export([fatal/1, fatal/2, fatal/3]).
-export([debug/1, debug/2, debug/3]).
-%% gen_server callbacks
--export([init/1, handle_call/3, handle_cast/2, handle_info/2,
- terminate/2, code_change/3]).
-
%% Application callbacks
-export([start/2, stop/1]).
-start_link(Default_logger) ->
- ?LOG("Starting process log4erl"),
- gen_server:start_link({local, ?MODULE}, ?MODULE, [Default_logger], []).
+%%======================================
+%% application callback functions
+%%======================================
+start(_Type, []) ->
+ ?LOG("Starting log4erl app~n"),
+ log4erl_sup:start_link(?DEFAULT_LOGGER).
+
+stop(_State) ->
+ log_filter_codegen:reset(),
+ ok.
add_logger(Logger) ->
try_msg({add_logger, Logger}).
%% Appender = {Appender, Name}
add_appender(Appender, Conf) ->
- try_msg({add_appender, Appender, Conf}).
+ try_msg({add_appender, ?DEFAULT_LOGGER ,Appender, Conf}).
%% Appender = {Appender, Name}
add_appender(Logger, Appender, Conf) ->
try_msg({add_appender, Logger, Appender, Conf}).
add_console_appender(AName, Conf) ->
- add_appender({console_appender, AName}, Conf).
+ add_appender(?DEFAULT_LOGGER, {console_appender, AName}, Conf).
add_console_appender(Logger, AName, Conf) ->
add_appender(Logger, {console_appender, AName}, Conf).
add_file_appender(AName, Conf) ->
- add_appender({file_appender, AName}, Conf).
+ add_appender(?DEFAULT_LOGGER, {file_appender, AName}, Conf).
add_file_appender(Logger, AName, Conf) ->
add_appender(Logger, {file_appender, AName}, Conf).
add_smtp_appender(Name, Conf) ->
- add_appender({smtp_appender, Name}, Conf).
+ add_appender(?DEFAULT_LOGGER, {smtp_appender, Name}, Conf).
add_smtp_appender(Logger, Name, Conf) ->
add_appender(Logger, {smtp_appender, Name}, Conf).
add_syslog_appender(Name, Conf) ->
- add_appender({syslog_appender, Name}, Conf).
+ add_appender(?DEFAULT_LOGGER, {syslog_appender, Name}, Conf).
add_syslog_appender(Logger, Name, Conf) ->
add_appender(Logger, {syslog_appender, Name}, Conf).
add_xml_appender(Name, Conf) ->
- add_appender({xml_appender, Name}, Conf).
+ add_appender(?DEFAULT_LOGGER, {xml_appender, Name}, Conf).
add_xml_appender(Logger, Name, Conf) ->
add_appender(Logger, {xml_appender, Name}, Conf).
add_dummy_appender(AName, Conf) ->
- add_appender({dummy_appender, AName}, Conf).
+ add_appender(?DEFAULT_LOGGER, {dummy_appender, AName}, Conf).
add_dummy_appender(Logger, AName, Conf) ->
add_appender(Logger, {dummy_appender, AName}, Conf).
get_appenders() ->
- try_msg(get_appenders).
+ try_msg({get_appenders, ?DEFAULT_LOGGER}).
get_appenders(Logger) ->
try_msg({get_appenders, Logger}).
@@ -101,12 +101,12 @@ conf(File) ->
log4erl_conf:conf(File).
change_format(Appender, Format) ->
- try_msg({change_format, Appender, Format}).
+ try_msg({change_format, ?DEFAULT_LOGGER, Appender, Format}).
change_format(Logger, Appender, Format) ->
try_msg({change_format, Logger, Appender, Format}).
change_level(Appender, Level) ->
- try_msg({change_level, Appender, Level}).
+ try_msg({change_level, ?DEFAULT_LOGGER, Appender, Level}).
change_level(Logger, Appender, Level) ->
try_msg({change_level, Logger, Appender, Level}).
@@ -119,29 +119,39 @@ error_logger_handler(Args) ->
%% For default logger
change_log_level(Level) ->
- try_msg({change_log_level, Level}).
+ try_msg({change_log_level, ?DEFAULT_LOGGER, Level}).
change_log_level(Logger, Level) ->
try_msg({change_log_level, Logger, Level}).
try_msg(Msg) ->
try
- gen_server:call(?MODULE, Msg)
+ handle_call(Msg)
catch
- exit:{noproc, _M} ->
- io:format("log4erl has not been initialized yet. To do so, please run~n"),
- io:format("> application:start(log4erl).~n"),
- {error, log4erl_not_started};
- E:M ->
- ?LOG2("Error message received by log4erl is ~p:~p~n",[E, M]),
- {E, M}
+ exit:{noproc, _M} ->
+ io:format("log4erl has not been initialized yet. To do so, please run~n"),
+ io:format("> application:start(log4erl).~n"),
+ {error, log4erl_not_started};
+ E:M ->
+ ?LOG2("Error message received by log4erl is ~p:~p~n",[E, M]),
+ {E, M}
end.
log(Level, Log) ->
log(Level, Log, []).
log(Level, Log, Data) ->
- try_msg({log, Level, Log, Data}).
+ %filter_log(Level, {log, ?DEFAULT_LOGGER, Level, Log, Data}).
+ log(?DEFAULT_LOGGER, Level, Log, Data).
log(Logger, Level, Log, Data) ->
- try_msg({log, Logger, Level, Log, Data}).
+ filter_log(Level, {log, Logger, Level, Log, Data}).
+
+filter_log(Level, Msg) ->
+ case log4erl_utils:to_log(log_filter:cutoff_level(), Level) of
+ true ->
+ try_msg(Msg);
+ false ->
+ ?LOG(">>--- Message filtered by cutoff logger~n"),
+ ok
+ end.
warn(Log) ->
log(warn, Log).
@@ -189,74 +199,18 @@ debug(Log, Data) ->
debug(Logger, Log, Data) ->
log(Logger, debug, Log, Data).
-%%======================================
-%% gen_server callback functions
-%%======================================
-init([Default_logger]) ->
- ?LOG2("starting log4erl server with default_logger ~p~n",[Default_logger]),
- {ok, {default_logger, Default_logger}}.
-
-%% No logger specified? use default logger
-handle_call({add_logger, Logger}, _From, State) ->
- R = log_manager:add_logger(Logger),
- {reply, R, State};
-handle_call({add_appender, Appender, Conf}, _From, {default_logger, DL} = State) ->
- R = log_manager:add_appender(DL, Appender, Conf),
- {reply, R, State};
-handle_call({add_appender, Logger, Appender, Conf}, _From, State) ->
- R = log_manager:add_appender(Logger, Appender, Conf),
- {reply, R, State};
-handle_call(get_appenders, _From, {default_logger, DL} = State) ->
- R = gen_event:which_handlers(DL),
- {reply, R, State};
-handle_call({get_appenders, Logger}, _From, State) ->
- R = gen_event:which_handlers(Logger),
- {reply, R, State};
-handle_call({change_level, Appender, Level}, _From, {default_logger, DL} = State) ->
- R = log_manager:change_level(DL, Appender, Level),
- {reply, R, State};
-handle_call({change_level, Logger, Appender, Level}, _From, State) ->
- R = log_manager:change_level(Logger, Appender, Level),
- {reply, R, State};
-handle_call({change_log_level, Level}, _From, {default_logger, DL} = State) ->
- R = log_manager:change_log_level(DL, Level),
- {reply, R, State};
-handle_call({change_log_level, Logger, Level}, _From, State) ->
- R = log_manager:change_log_level(Logger, Level),
- {reply, R, State};
-handle_call({change_format, Appender, Format}, _From, {default_logger,DL} = State) ->
- R = log_manager:change_format(DL, Appender, Format),
- {reply, R, State};
-handle_call({change_format, Logger, Appender, Format}, _From, State) ->
- R = log_manager:change_format(Logger, Appender, Format),
- {reply, R, State};
-handle_call({log, Level, Log, Data}, _From, {default_logger, Logger} = State) ->
- R = log_manager:log(Logger, Level, Log, Data),
- {reply, R, State};
-handle_call({log, Logger, Level, Log, Data} , _From, State) ->
- R = log_manager:log(Logger, Level, Log, Data),
- {reply, R, State}.
-
-handle_cast(_Msg, State) ->
- {noreply, State}.
-
-handle_info(_Info, State) ->
- {noreply, State}.
-
-terminate(_Reason, _State) ->
- ok.
-
-code_change(_OldVsn, State, _Extra) ->
- {ok, State}.
-
-%%======================================
-%% application callback functions
-%%======================================
-start(_Type, [Arg]) ->
- ?LOG("Starting log4erl app~n"),
- log4erl_sup:start_link(Arg).
-
-stop(_State) ->
- ok.
-
+handle_call({add_logger, Logger}) ->
+ log_manager:add_logger(Logger);
+handle_call({add_appender, Logger, Appender, Conf}) ->
+ log_manager:add_appender(Logger, Appender, Conf);
+handle_call({get_appenders, Logger}) ->
+ gen_event:which_handlers(Logger);
+handle_call({change_level, Logger, Appender, Level}) ->
+ log_manager:change_level(Logger, Appender, Level);
+handle_call({change_log_level, Logger, Level}) ->
+ log_manager:change_log_level(Logger, Level);
+handle_call({change_format, Logger, Appender, Format}) ->
+ log_manager:change_format(Logger, Appender, Format);
+handle_call({log, Logger, Level, Log, Data}) ->
+ log_manager:log(Logger, Level, Log, Data).
View
8 src/log4erl_conf.erl
@@ -31,12 +31,14 @@ conf(File) ->
traverse([]) ->
ok;
traverse([H|Tree]) ->
- logger(H),
+ element(H),
traverse(Tree).
-logger({default_logger, Appenders}) ->
+element({cutoff_level, CutoffLevel}) ->
+ log_filter_codegen:set_cutoff_level(CutoffLevel);
+element({default_logger, Appenders}) ->
appenders(Appenders);
-logger({logger, Logger, Appenders}) ->
+element({logger, Logger, Appenders}) ->
log4erl:add_logger(Logger),
appenders(Logger, Appenders).
View
32 src/log4erl_lex.erl
@@ -409,19 +409,15 @@ yystate(15, [62|Ics], Line, Tlen, Action, Alen) ->
yystate(15, Ics, Line, Tlen+1, Action, Alen);
yystate(15, [60|Ics], Line, Tlen, Action, Alen) ->
yystate(15, Ics, Line, Tlen+1, Action, Alen);
-yystate(15, [45|Ics], Line, Tlen, Action, Alen) ->
- yystate(15, Ics, Line, Tlen+1, Action, Alen);
-yystate(15, [46|Ics], Line, Tlen, Action, Alen) ->
- yystate(15, Ics, Line, Tlen+1, Action, Alen);
yystate(15, [34|Ics], Line, Tlen, Action, Alen) ->
yystate(19, Ics, Line, Tlen+1, Action, Alen);
yystate(15, [32|Ics], Line, Tlen, Action, Alen) ->
yystate(15, Ics, Line, Tlen+1, Action, Alen);
yystate(15, [C|Ics], Line, Tlen, Action, Alen) when C >= 35, C =< 37 ->
yystate(15, Ics, Line, Tlen+1, Action, Alen);
-yystate(15, [C|Ics], Line, Tlen, Action, Alen) when C >= 40, C =< 42 ->
+yystate(15, [C|Ics], Line, Tlen, Action, Alen) when C >= 40, C =< 43 ->
yystate(15, Ics, Line, Tlen+1, Action, Alen);
-yystate(15, [C|Ics], Line, Tlen, Action, Alen) when C >= 48, C =< 58 ->
+yystate(15, [C|Ics], Line, Tlen, Action, Alen) when C >= 45, C =< 58 ->
yystate(15, Ics, Line, Tlen+1, Action, Alen);
yystate(15, [C|Ics], Line, Tlen, Action, Alen) when C >= 64, C =< 91 ->
yystate(15, Ics, Line, Tlen+1, Action, Alen);
@@ -473,17 +469,13 @@ yystate(11, [62|Ics], Line, Tlen, Action, Alen) ->
yystate(15, Ics, Line, Tlen+1, Action, Alen);
yystate(11, [60|Ics], Line, Tlen, Action, Alen) ->
yystate(15, Ics, Line, Tlen+1, Action, Alen);
-yystate(11, [45|Ics], Line, Tlen, Action, Alen) ->
- yystate(15, Ics, Line, Tlen+1, Action, Alen);
-yystate(11, [46|Ics], Line, Tlen, Action, Alen) ->
- yystate(15, Ics, Line, Tlen+1, Action, Alen);
yystate(11, [32|Ics], Line, Tlen, Action, Alen) ->
yystate(15, Ics, Line, Tlen+1, Action, Alen);
yystate(11, [C|Ics], Line, Tlen, Action, Alen) when C >= 35, C =< 37 ->
yystate(15, Ics, Line, Tlen+1, Action, Alen);
-yystate(11, [C|Ics], Line, Tlen, Action, Alen) when C >= 40, C =< 42 ->
+yystate(11, [C|Ics], Line, Tlen, Action, Alen) when C >= 40, C =< 43 ->
yystate(15, Ics, Line, Tlen+1, Action, Alen);
-yystate(11, [C|Ics], Line, Tlen, Action, Alen) when C >= 48, C =< 58 ->
+yystate(11, [C|Ics], Line, Tlen, Action, Alen) when C >= 45, C =< 58 ->
yystate(15, Ics, Line, Tlen+1, Action, Alen);
yystate(11, [C|Ics], Line, Tlen, Action, Alen) when C >= 64, C =< 91 ->
yystate(15, Ics, Line, Tlen+1, Action, Alen);
@@ -571,17 +563,13 @@ yystate(4, [62|Ics], Line, Tlen, Action, Alen) ->
yystate(0, Ics, Line, Tlen+1, Action, Alen);
yystate(4, [60|Ics], Line, Tlen, Action, Alen) ->
yystate(0, Ics, Line, Tlen+1, Action, Alen);
-yystate(4, [45|Ics], Line, Tlen, Action, Alen) ->
- yystate(0, Ics, Line, Tlen+1, Action, Alen);
-yystate(4, [46|Ics], Line, Tlen, Action, Alen) ->
- yystate(0, Ics, Line, Tlen+1, Action, Alen);
yystate(4, [32|Ics], Line, Tlen, Action, Alen) ->
yystate(0, Ics, Line, Tlen+1, Action, Alen);
yystate(4, [C|Ics], Line, Tlen, Action, Alen) when C >= 35, C =< 37 ->
yystate(0, Ics, Line, Tlen+1, Action, Alen);
-yystate(4, [C|Ics], Line, Tlen, Action, Alen) when C >= 40, C =< 42 ->
+yystate(4, [C|Ics], Line, Tlen, Action, Alen) when C >= 40, C =< 43 ->
yystate(0, Ics, Line, Tlen+1, Action, Alen);
-yystate(4, [C|Ics], Line, Tlen, Action, Alen) when C >= 48, C =< 58 ->
+yystate(4, [C|Ics], Line, Tlen, Action, Alen) when C >= 45, C =< 58 ->
yystate(0, Ics, Line, Tlen+1, Action, Alen);
yystate(4, [C|Ics], Line, Tlen, Action, Alen) when C >= 64, C =< 91 ->
yystate(0, Ics, Line, Tlen+1, Action, Alen);
@@ -623,19 +611,15 @@ yystate(0, [62|Ics], Line, Tlen, Action, Alen) ->
yystate(0, Ics, Line, Tlen+1, Action, Alen);
yystate(0, [60|Ics], Line, Tlen, Action, Alen) ->
yystate(0, Ics, Line, Tlen+1, Action, Alen);
-yystate(0, [45|Ics], Line, Tlen, Action, Alen) ->
- yystate(0, Ics, Line, Tlen+1, Action, Alen);
-yystate(0, [46|Ics], Line, Tlen, Action, Alen) ->
- yystate(0, Ics, Line, Tlen+1, Action, Alen);
yystate(0, [39|Ics], Line, Tlen, Action, Alen) ->
yystate(3, Ics, Line, Tlen+1, Action, Alen);
yystate(0, [32|Ics], Line, Tlen, Action, Alen) ->
yystate(0, Ics, Line, Tlen+1, Action, Alen);
yystate(0, [C|Ics], Line, Tlen, Action, Alen) when C >= 35, C =< 37 ->
yystate(0, Ics, Line, Tlen+1, Action, Alen);
-yystate(0, [C|Ics], Line, Tlen, Action, Alen) when C >= 40, C =< 42 ->
+yystate(0, [C|Ics], Line, Tlen, Action, Alen) when C >= 40, C =< 43 ->
yystate(0, Ics, Line, Tlen+1, Action, Alen);
-yystate(0, [C|Ics], Line, Tlen, Action, Alen) when C >= 48, C =< 58 ->
+yystate(0, [C|Ics], Line, Tlen, Action, Alen) when C >= 45, C =< 58 ->
yystate(0, Ics, Line, Tlen+1, Action, Alen);
yystate(0, [C|Ics], Line, Tlen, Action, Alen) when C >= 64, C =< 91 ->
yystate(0, Ics, Line, Tlen+1, Action, Alen);
View
3  src/log4erl_lex.xrl
@@ -2,7 +2,7 @@ Definitions.
D = [0-9]
L = [A-Z0-9a-z_]
-LS = [\[\]A-Z0-9a-z_\s\%\*\$\#\@\(\)\.\-\>\<\:]
+LS = [][A-Z0-9a-z_\s%*$#@().><:/\-\+]
WS = ([\000-\s]|%.*)
Rules.
@@ -10,7 +10,6 @@ Rules.
logger : {token,{loger,TokenLine, list_to_atom(TokenChars)}}.
default : {token,{default,TokenLine, list_to_atom(TokenChars)}}.
{D}+ : {token,{integer,TokenLine,list_to_integer(TokenChars)}}.
-%%{L}+_appender : {token,{apender,TokenLine,list_to_atom(TokenChars)}}.
{L}+ : {token,{atom,TokenLine,list_to_atom(TokenChars)}}.
'{LS}+' : {token,{val,TokenLine,strip(TokenChars,TokenLen)}}.
"{LS}+" : {token,{val,TokenLine,strip(TokenChars,TokenLen)}}.
View
378 src/log4erl_parser.erl
@@ -1,6 +1,6 @@
-module(log4erl_parser).
-export([parse/1, parse_and_scan/1, format_error/1]).
--file("log4erl_parser.yrl", 30).
+-file("log4erl_parser.yrl", 33).
unwrap({_,_,V}) -> V.
@@ -163,12 +163,12 @@ yeccpars2(0=S, Cat, Ss, Stack, T, Ts, Tzr) ->
%% yeccpars2_1(S, Cat, Ss, Stack, T, Ts, Tzr);
%% yeccpars2(2=S, Cat, Ss, Stack, T, Ts, Tzr) ->
%% yeccpars2_2(S, Cat, Ss, Stack, T, Ts, Tzr);
-yeccpars2(3=S, Cat, Ss, Stack, T, Ts, Tzr) ->
- yeccpars2_3(S, Cat, Ss, Stack, T, Ts, Tzr);
+%% yeccpars2(3=S, Cat, Ss, Stack, T, Ts, Tzr) ->
+%% yeccpars2_3(S, Cat, Ss, Stack, T, Ts, Tzr);
%% yeccpars2(4=S, Cat, Ss, Stack, T, Ts, Tzr) ->
%% yeccpars2_4(S, Cat, Ss, Stack, T, Ts, Tzr);
-yeccpars2(5=S, Cat, Ss, Stack, T, Ts, Tzr) ->
- yeccpars2_5(S, Cat, Ss, Stack, T, Ts, Tzr);
+%% yeccpars2(5=S, Cat, Ss, Stack, T, Ts, Tzr) ->
+%% yeccpars2_5(S, Cat, Ss, Stack, T, Ts, Tzr);
yeccpars2(6=S, Cat, Ss, Stack, T, Ts, Tzr) ->
yeccpars2_6(S, Cat, Ss, Stack, T, Ts, Tzr);
yeccpars2(7=S, Cat, Ss, Stack, T, Ts, Tzr) ->
@@ -178,158 +178,165 @@ yeccpars2(8=S, Cat, Ss, Stack, T, Ts, Tzr) ->
yeccpars2(9=S, Cat, Ss, Stack, T, Ts, Tzr) ->
yeccpars2_9(S, Cat, Ss, Stack, T, Ts, Tzr);
%% yeccpars2(10=S, Cat, Ss, Stack, T, Ts, Tzr) ->
-%% yeccpars2_9(S, Cat, Ss, Stack, T, Ts, Tzr);
-%% yeccpars2(11=S, Cat, Ss, Stack, T, Ts, Tzr) ->
-%% yeccpars2_11(S, Cat, Ss, Stack, T, Ts, Tzr);
-%% yeccpars2(12=S, Cat, Ss, Stack, T, Ts, Tzr) ->
-%% yeccpars2_12(S, Cat, Ss, Stack, T, Ts, Tzr);
+%% yeccpars2_10(S, Cat, Ss, Stack, T, Ts, Tzr);
+yeccpars2(11=S, Cat, Ss, Stack, T, Ts, Tzr) ->
+ yeccpars2_11(S, Cat, Ss, Stack, T, Ts, Tzr);
+yeccpars2(12=S, Cat, Ss, Stack, T, Ts, Tzr) ->
+ yeccpars2_12(S, Cat, Ss, Stack, T, Ts, Tzr);
%% yeccpars2(13=S, Cat, Ss, Stack, T, Ts, Tzr) ->
-%% yeccpars2_13(S, Cat, Ss, Stack, T, Ts, Tzr);
-yeccpars2(14=S, Cat, Ss, Stack, T, Ts, Tzr) ->
- yeccpars2_14(S, Cat, Ss, Stack, T, Ts, Tzr);
+%% yeccpars2_12(S, Cat, Ss, Stack, T, Ts, Tzr);
+%% yeccpars2(14=S, Cat, Ss, Stack, T, Ts, Tzr) ->
+%% yeccpars2_14(S, Cat, Ss, Stack, T, Ts, Tzr);
%% yeccpars2(15=S, Cat, Ss, Stack, T, Ts, Tzr) ->
%% yeccpars2_15(S, Cat, Ss, Stack, T, Ts, Tzr);
-yeccpars2(16=S, Cat, Ss, Stack, T, Ts, Tzr) ->
- yeccpars2_9(S, Cat, Ss, Stack, T, Ts, Tzr);
-%% yeccpars2(17=S, Cat, Ss, Stack, T, Ts, Tzr) ->
-%% yeccpars2_17(S, Cat, Ss, Stack, T, Ts, Tzr);
+%% yeccpars2(16=S, Cat, Ss, Stack, T, Ts, Tzr) ->
+%% yeccpars2_16(S, Cat, Ss, Stack, T, Ts, Tzr);
+yeccpars2(17=S, Cat, Ss, Stack, T, Ts, Tzr) ->
+ yeccpars2_17(S, Cat, Ss, Stack, T, Ts, Tzr);
%% yeccpars2(18=S, Cat, Ss, Stack, T, Ts, Tzr) ->
%% yeccpars2_18(S, Cat, Ss, Stack, T, Ts, Tzr);
-%% yeccpars2(19=S, Cat, Ss, Stack, T, Ts, Tzr) ->
-%% yeccpars2_19(S, Cat, Ss, Stack, T, Ts, Tzr);
-yeccpars2(20=S, Cat, Ss, Stack, T, Ts, Tzr) ->
- yeccpars2_9(S, Cat, Ss, Stack, T, Ts, Tzr);
+yeccpars2(19=S, Cat, Ss, Stack, T, Ts, Tzr) ->
+ yeccpars2_12(S, Cat, Ss, Stack, T, Ts, Tzr);
+%% yeccpars2(20=S, Cat, Ss, Stack, T, Ts, Tzr) ->
+%% yeccpars2_20(S, Cat, Ss, Stack, T, Ts, Tzr);
%% yeccpars2(21=S, Cat, Ss, Stack, T, Ts, Tzr) ->
%% yeccpars2_21(S, Cat, Ss, Stack, T, Ts, Tzr);
yeccpars2(22=S, Cat, Ss, Stack, T, Ts, Tzr) ->
- yeccpars2_22(S, Cat, Ss, Stack, T, Ts, Tzr);
-yeccpars2(23=S, Cat, Ss, Stack, T, Ts, Tzr) ->
- yeccpars2_9(S, Cat, Ss, Stack, T, Ts, Tzr);
-%% yeccpars2(24=S, Cat, Ss, Stack, T, Ts, Tzr) ->
-%% yeccpars2_24(S, Cat, Ss, Stack, T, Ts, Tzr);
+ yeccpars2_12(S, Cat, Ss, Stack, T, Ts, Tzr);
+%% yeccpars2(23=S, Cat, Ss, Stack, T, Ts, Tzr) ->
+%% yeccpars2_23(S, Cat, Ss, Stack, T, Ts, Tzr);
+yeccpars2(24=S, Cat, Ss, Stack, T, Ts, Tzr) ->
+ yeccpars2_24(S, Cat, Ss, Stack, T, Ts, Tzr);
yeccpars2(25=S, Cat, Ss, Stack, T, Ts, Tzr) ->
- yeccpars2_9(S, Cat, Ss, Stack, T, Ts, Tzr);
+ yeccpars2_12(S, Cat, Ss, Stack, T, Ts, Tzr);
%% yeccpars2(26=S, Cat, Ss, Stack, T, Ts, Tzr) ->
%% yeccpars2_26(S, Cat, Ss, Stack, T, Ts, Tzr);
yeccpars2(27=S, Cat, Ss, Stack, T, Ts, Tzr) ->
yeccpars2_27(S, Cat, Ss, Stack, T, Ts, Tzr);
yeccpars2(28=S, Cat, Ss, Stack, T, Ts, Tzr) ->
- yeccpars2_9(S, Cat, Ss, Stack, T, Ts, Tzr);
+ yeccpars2_12(S, Cat, Ss, Stack, T, Ts, Tzr);
%% yeccpars2(29=S, Cat, Ss, Stack, T, Ts, Tzr) ->
%% yeccpars2_29(S, Cat, Ss, Stack, T, Ts, Tzr);
yeccpars2(30=S, Cat, Ss, Stack, T, Ts, Tzr) ->
yeccpars2_30(S, Cat, Ss, Stack, T, Ts, Tzr);
%% yeccpars2(31=S, Cat, Ss, Stack, T, Ts, Tzr) ->
%% yeccpars2_31(S, Cat, Ss, Stack, T, Ts, Tzr);
+%% yeccpars2(32=S, Cat, Ss, Stack, T, Ts, Tzr) ->
+%% yeccpars2_32(S, Cat, Ss, Stack, T, Ts, Tzr);
+yeccpars2(33=S, Cat, Ss, Stack, T, Ts, Tzr) ->
+ yeccpars2_12(S, Cat, Ss, Stack, T, Ts, Tzr);
+%% yeccpars2(34=S, Cat, Ss, Stack, T, Ts, Tzr) ->
+%% yeccpars2_34(S, Cat, Ss, Stack, T, Ts, Tzr);
yeccpars2(Other, _, _, _, _, _, _) ->
erlang:error({yecc_bug,"1.3",{missing_state_in_action_table, Other}}).
yeccpars2_0(S, loger, Ss, Stack, T, Ts, Tzr) ->
- yeccpars1(S, 3, Ss, Stack, T, Ts, Tzr).
+ yeccpars1(S, 8, Ss, Stack, T, Ts, Tzr);
+yeccpars2_0(S, Cat, Ss, Stack, T, Ts, Tzr) ->
+ yeccpars2_12(S, Cat, Ss, Stack, T, Ts, Tzr).
-yeccpars2_1(_S, '$end', _Ss, Stack, _T, _Ts, _Tzr) ->
- {ok, hd(Stack)}.
+yeccpars2_1(S, '=', Ss, Stack, T, Ts, Tzr) ->
+ yeccpars1(S, 33, Ss, Stack, T, Ts, Tzr).
yeccpars2_2(S, loger, Ss, Stack, T, Ts, Tzr) ->
- yeccpars1(S, 3, Ss, Stack, T, Ts, Tzr);
-yeccpars2_2(_S, Cat, Ss, Stack, T, Ts, Tzr) ->
- NewStack = yeccpars2_2_(Stack),
- yeccgoto_loggers(hd(Ss), Cat, Ss, NewStack, T, Ts, Tzr).
+ yeccpars1(S, 8, Ss, Stack, T, Ts, Tzr).
-yeccpars2_3(S, default, Ss, Stack, T, Ts, Tzr) ->
- yeccpars1(S, 6, Ss, Stack, T, Ts, Tzr);
-yeccpars2_3(S, '{', Ss, Stack, T, Ts, Tzr) ->
- yeccpars1(S, 9, Ss, Stack, T, Ts, Tzr);
-yeccpars2_3(S, Cat, Ss, Stack, T, Ts, Tzr) ->
- yeccpars2_9(S, Cat, Ss, Stack, T, Ts, Tzr).
+yeccpars2_3(_S, Cat, Ss, Stack, T, Ts, Tzr) ->
+ yeccgoto_cutoff_level(hd(Ss), Cat, Ss, Stack, T, Ts, Tzr).
-yeccpars2_4(S, '{', Ss, Stack, T, Ts, Tzr) ->
- yeccpars1(S, 28, Ss, Stack, T, Ts, Tzr).
+yeccpars2_4(S, loger, Ss, Stack, T, Ts, Tzr) ->
+ yeccpars1(S, 8, Ss, Stack, T, Ts, Tzr);
+yeccpars2_4(_S, Cat, Ss, Stack, T, Ts, Tzr) ->
+ NewStack = yeccpars2_4_(Stack),
+ yeccgoto_loggers(hd(Ss), Cat, Ss, NewStack, T, Ts, Tzr).
-yeccpars2_5(_S, Cat, Ss, Stack, T, Ts, Tzr) ->
- NewStack = yeccpars2_5_(Stack),
- yeccgoto_value(hd(Ss), Cat, Ss, NewStack, T, Ts, Tzr).
+yeccpars2_5(_S, '$end', _Ss, Stack, _T, _Ts, _Tzr) ->
+ {ok, hd(Stack)}.
-yeccpars2_6(S, '{', Ss, Stack, T, Ts, Tzr) ->
- yeccpars1(S, 25, Ss, Stack, T, Ts, Tzr).
+yeccpars2_6(_S, Cat, Ss, Stack, T, Ts, Tzr) ->
+ NewStack = yeccpars2_6_(Stack),
+ yeccgoto_value(hd(Ss), Cat, Ss, NewStack, T, Ts, Tzr).
yeccpars2_7(_S, Cat, Ss, Stack, T, Ts, Tzr) ->
NewStack = yeccpars2_7_(Stack),
yeccgoto_value(hd(Ss), Cat, Ss, NewStack, T, Ts, Tzr).
-yeccpars2_8(_S, Cat, Ss, Stack, T, Ts, Tzr) ->
- NewStack = yeccpars2_8_(Stack),
- yeccgoto_value(hd(Ss), Cat, Ss, NewStack, T, Ts, Tzr).
+yeccpars2_8(S, default, Ss, Stack, T, Ts, Tzr) ->
+ yeccpars1(S, 11, Ss, Stack, T, Ts, Tzr);
+yeccpars2_8(S, '{', Ss, Stack, T, Ts, Tzr) ->
+ yeccpars1(S, 12, Ss, Stack, T, Ts, Tzr);
+yeccpars2_8(S, Cat, Ss, Stack, T, Ts, Tzr) ->
+ yeccpars2_12(S, Cat, Ss, Stack, T, Ts, Tzr).
-yeccpars2_9(S, atom, Ss, Stack, T, Ts, Tzr) ->
- yeccpars1(S, 5, Ss, Stack, T, Ts, Tzr);
-yeccpars2_9(S, integer, Ss, Stack, T, Ts, Tzr) ->
- yeccpars1(S, 7, Ss, Stack, T, Ts, Tzr);
-yeccpars2_9(S, val, Ss, Stack, T, Ts, Tzr) ->
- yeccpars1(S, 8, Ss, Stack, T, Ts, Tzr).
+yeccpars2_9(_S, Cat, Ss, Stack, T, Ts, Tzr) ->
+ NewStack = yeccpars2_9_(Stack),
+ yeccgoto_value(hd(Ss), Cat, Ss, NewStack, T, Ts, Tzr).
-%% yeccpars2_10: see yeccpars2_9
+yeccpars2_10(S, '{', Ss, Stack, T, Ts, Tzr) ->
+ yeccpars1(S, 28, Ss, Stack, T, Ts, Tzr).
-yeccpars2_11(S, '}', Ss, Stack, T, Ts, Tzr) ->
- yeccpars1(S, 14, Ss, Stack, T, Ts, Tzr).
+yeccpars2_11(S, '{', Ss, Stack, T, Ts, Tzr) ->
+ yeccpars1(S, 25, Ss, Stack, T, Ts, Tzr).
yeccpars2_12(S, atom, Ss, Stack, T, Ts, Tzr) ->
- yeccpars1(S, 5, Ss, Stack, T, Ts, Tzr);
+ yeccpars1(S, 6, Ss, Stack, T, Ts, Tzr);
yeccpars2_12(S, integer, Ss, Stack, T, Ts, Tzr) ->
yeccpars1(S, 7, Ss, Stack, T, Ts, Tzr);
yeccpars2_12(S, val, Ss, Stack, T, Ts, Tzr) ->
- yeccpars1(S, 8, Ss, Stack, T, Ts, Tzr);
-yeccpars2_12(_S, Cat, Ss, Stack, T, Ts, Tzr) ->
- NewStack = yeccpars2_12_(Stack),
+ yeccpars1(S, 9, Ss, Stack, T, Ts, Tzr).
+
+%% yeccpars2_13: see yeccpars2_12
+
+yeccpars2_14(S, '}', Ss, Stack, T, Ts, Tzr) ->
+ yeccpars1(S, 17, Ss, Stack, T, Ts, Tzr).
+
+yeccpars2_15(S, atom, Ss, Stack, T, Ts, Tzr) ->
+ yeccpars1(S, 6, Ss, Stack, T, Ts, Tzr);
+yeccpars2_15(S, integer, Ss, Stack, T, Ts, Tzr) ->
+ yeccpars1(S, 7, Ss, Stack, T, Ts, Tzr);
+yeccpars2_15(S, val, Ss, Stack, T, Ts, Tzr) ->
+ yeccpars1(S, 9, Ss, Stack, T, Ts, Tzr);
+yeccpars2_15(_S, Cat, Ss, Stack, T, Ts, Tzr) ->
+ NewStack = yeccpars2_15_(Stack),
yeccgoto_appenders(hd(Ss), Cat, Ss, NewStack, T, Ts, Tzr).
-yeccpars2_13(_S, Cat, Ss, Stack, T, Ts, Tzr) ->
+yeccpars2_16(_S, Cat, Ss, Stack, T, Ts, Tzr) ->
[_|Nss] = Ss,
- NewStack = yeccpars2_13_(Stack),
+ NewStack = yeccpars2_16_(Stack),
yeccgoto_appenders(hd(Nss), Cat, Nss, NewStack, T, Ts, Tzr).
-yeccpars2_14(_S, Cat, Ss, Stack, T, Ts, Tzr) ->
+yeccpars2_17(_S, Cat, Ss, Stack, T, Ts, Tzr) ->
[_,_,_|Nss] = Ss,
- NewStack = yeccpars2_14_(Stack),
+ NewStack = yeccpars2_17_(Stack),
yeccgoto_logger(hd(Nss), Cat, Nss, NewStack, T, Ts, Tzr).
-yeccpars2_15(S, '{', Ss, Stack, T, Ts, Tzr) ->
- yeccpars1(S, 16, Ss, Stack, T, Ts, Tzr).
+yeccpars2_18(S, '{', Ss, Stack, T, Ts, Tzr) ->
+ yeccpars1(S, 19, Ss, Stack, T, Ts, Tzr).
-%% yeccpars2_16: see yeccpars2_9
+%% yeccpars2_19: see yeccpars2_12
-yeccpars2_17(S, '=', Ss, Stack, T, Ts, Tzr) ->
- yeccpars1(S, 23, Ss, Stack, T, Ts, Tzr).
+yeccpars2_20(S, '}', Ss, Stack, T, Ts, Tzr) ->
+ yeccpars1(S, 24, Ss, Stack, T, Ts, Tzr).
-yeccpars2_18(S, '}', Ss, Stack, T, Ts, Tzr) ->
- yeccpars1(S, 22, Ss, Stack, T, Ts, Tzr).
-
-yeccpars2_19(S, ',', Ss, Stack, T, Ts, Tzr) ->
- yeccpars1(S, 20, Ss, Stack, T, Ts, Tzr);
-yeccpars2_19(_S, Cat, Ss, Stack, T, Ts, Tzr) ->
- NewStack = yeccpars2_19_(Stack),
+yeccpars2_21(S, ',', Ss, Stack, T, Ts, Tzr) ->
+ yeccpars1(S, 22, Ss, Stack, T, Ts, Tzr);
+yeccpars2_21(_S, Cat, Ss, Stack, T, Ts, Tzr) ->
+ NewStack = yeccpars2_21_(Stack),
yeccgoto_props(hd(Ss), Cat, Ss, NewStack, T, Ts, Tzr).
-%% yeccpars2_20: see yeccpars2_9
+%% yeccpars2_22: see yeccpars2_12
-yeccpars2_21(_S, Cat, Ss, Stack, T, Ts, Tzr) ->
+yeccpars2_23(_S, Cat, Ss, Stack, T, Ts, Tzr) ->
[_,_|Nss] = Ss,
- NewStack = yeccpars2_21_(Stack),
+ NewStack = yeccpars2_23_(Stack),
yeccgoto_props(hd(Nss), Cat, Nss, NewStack, T, Ts, Tzr).
-yeccpars2_22(_S, Cat, Ss, Stack, T, Ts, Tzr) ->
- [_,_,_,_|Nss] = Ss,
- NewStack = yeccpars2_22_(Stack),
- yeccgoto_appender(hd(Nss), Cat, Nss, NewStack, T, Ts, Tzr).
-
-%% yeccpars2_23: see yeccpars2_9
-
yeccpars2_24(_S, Cat, Ss, Stack, T, Ts, Tzr) ->
- [_,_|Nss] = Ss,
+ [_,_,_,_|Nss] = Ss,
NewStack = yeccpars2_24_(Stack),
- yeccgoto_prop(hd(Nss), Cat, Nss, NewStack, T, Ts, Tzr).
+ yeccgoto_appender(hd(Nss), Cat, Nss, NewStack, T, Ts, Tzr).
-%% yeccpars2_25: see yeccpars2_9
+%% yeccpars2_25: see yeccpars2_12
yeccpars2_26(S, '}', Ss, Stack, T, Ts, Tzr) ->
yeccpars1(S, 27, Ss, Stack, T, Ts, Tzr).
@@ -339,7 +346,7 @@ yeccpars2_27(_S, Cat, Ss, Stack, T, Ts, Tzr) ->
NewStack = yeccpars2_27_(Stack),
yeccgoto_logger(hd(Nss), Cat, Nss, NewStack, T, Ts, Tzr).
-%% yeccpars2_28: see yeccpars2_9
+%% yeccpars2_28: see yeccpars2_12
yeccpars2_29(S, '}', Ss, Stack, T, Ts, Tzr) ->
yeccpars1(S, 30, Ss, Stack, T, Ts, Tzr).
@@ -354,153 +361,168 @@ yeccpars2_31(_S, Cat, Ss, Stack, T, Ts, Tzr) ->
NewStack = yeccpars2_31_(Stack),
yeccgoto_loggers(hd(Nss), Cat, Nss, NewStack, T, Ts, Tzr).
-yeccgoto_appender(9, Cat, Ss, Stack, T, Ts, Tzr) ->
- yeccpars2_12(12, Cat, Ss, Stack, T, Ts, Tzr);
+yeccpars2_32(_S, Cat, Ss, Stack, T, Ts, Tzr) ->
+ [_|Nss] = Ss,
+ NewStack = yeccpars2_32_(Stack),
+ yeccgoto_cutoff_level(hd(Nss), Cat, Nss, NewStack, T, Ts, Tzr).
+
+%% yeccpars2_33: see yeccpars2_12
+
+yeccpars2_34(_S, Cat, Ss, Stack, T, Ts, Tzr) ->
+ [_,_|Nss] = Ss,
+ NewStack = yeccpars2_34_(Stack),
+ yeccgoto_prop(hd(Nss), Cat, Nss, NewStack, T, Ts, Tzr).
+
yeccgoto_appender(12, Cat, Ss, Stack, T, Ts, Tzr) ->
- yeccpars2_12(12, Cat, Ss, Stack, T, Ts, Tzr);
+ yeccpars2_15(15, Cat, Ss, Stack, T, Ts, Tzr);
+yeccgoto_appender(15, Cat, Ss, Stack, T, Ts, Tzr) ->
+ yeccpars2_15(15, Cat, Ss, Stack, T, Ts, Tzr);
yeccgoto_appender(25, Cat, Ss, Stack, T, Ts, Tzr) ->
- yeccpars2_12(12, Cat, Ss, Stack, T, Ts, Tzr);
+ yeccpars2_15(15, Cat, Ss, Stack, T, Ts, Tzr);
yeccgoto_appender(28, Cat, Ss, Stack, T, Ts, Tzr) ->
- yeccpars2_12(12, Cat, Ss, Stack, T, Ts, Tzr).
+ yeccpars2_15(15, Cat, Ss, Stack, T, Ts, Tzr).
-yeccgoto_appenders(9, Cat, Ss, Stack, T, Ts, Tzr) ->
- yeccpars2_11(11, Cat, Ss, Stack, T, Ts, Tzr);
-yeccgoto_appenders(12=_S, Cat, Ss, Stack, T, Ts, Tzr) ->
- yeccpars2_13(_S, Cat, Ss, Stack, T, Ts, Tzr);
+yeccgoto_appenders(12, Cat, Ss, Stack, T, Ts, Tzr) ->
+ yeccpars2_14(14, Cat, Ss, Stack, T, Ts, Tzr);
+yeccgoto_appenders(15=_S, Cat, Ss, Stack, T, Ts, Tzr) ->
+ yeccpars2_16(_S, Cat, Ss, Stack, T, Ts, Tzr);
yeccgoto_appenders(25, Cat, Ss, Stack, T, Ts, Tzr) ->
yeccpars2_26(26, Cat, Ss, Stack, T, Ts, Tzr);
yeccgoto_appenders(28, Cat, Ss, Stack, T, Ts, Tzr) ->
yeccpars2_29(29, Cat, Ss, Stack, T, Ts, Tzr).
+yeccgoto_cutoff_level(0, Cat, Ss, Stack, T, Ts, Tzr) ->
+ yeccpars2_5(5, Cat, Ss, Stack, T, Ts, Tzr).
+
yeccgoto_logger(0, Cat, Ss, Stack, T, Ts, Tzr) ->
- yeccpars2_2(2, Cat, Ss, Stack, T, Ts, Tzr);
+ yeccpars2_4(4, Cat, Ss, Stack, T, Ts, Tzr);
yeccgoto_logger(2, Cat, Ss, Stack, T, Ts, Tzr) ->
- yeccpars2_2(2, Cat, Ss, Stack, T, Ts, Tzr).
+ yeccpars2_4(4, Cat, Ss, Stack, T, Ts, Tzr);
+yeccgoto_logger(4, Cat, Ss, Stack, T, Ts, Tzr) ->
+ yeccpars2_4(4, Cat, Ss, Stack, T, Ts, Tzr).
-yeccgoto_loggers(0, Cat, Ss, Stack, T, Ts, Tzr) ->
- yeccpars2_1(1, Cat, Ss, Stack, T, Ts, Tzr);
+yeccgoto_loggers(0=_S, Cat, Ss, Stack, T, Ts, Tzr) ->
+ yeccpars2_3(_S, Cat, Ss, Stack, T, Ts, Tzr);
yeccgoto_loggers(2=_S, Cat, Ss, Stack, T, Ts, Tzr) ->
+ yeccpars2_32(_S, Cat, Ss, Stack, T, Ts, Tzr);
+yeccgoto_loggers(4=_S, Cat, Ss, Stack, T, Ts, Tzr) ->
yeccpars2_31(_S, Cat, Ss, Stack, T, Ts, Tzr).
-yeccgoto_prop(16, Cat, Ss, Stack, T, Ts, Tzr) ->
- yeccpars2_19(19, Cat, Ss, Stack, T, Ts, Tzr);
-yeccgoto_prop(20, Cat, Ss, Stack, T, Ts, Tzr) ->
- yeccpars2_19(19, Cat, Ss, Stack, T, Ts, Tzr).
+yeccgoto_prop(0, Cat, Ss, Stack, T, Ts, Tzr) ->
+ yeccpars2_2(2, Cat, Ss, Stack, T, Ts, Tzr);
+yeccgoto_prop(19, Cat, Ss, Stack, T, Ts, Tzr) ->
+ yeccpars2_21(21, Cat, Ss, Stack, T, Ts, Tzr);
+yeccgoto_prop(22, Cat, Ss, Stack, T, Ts, Tzr) ->
+ yeccpars2_21(21, Cat, Ss, Stack, T, Ts, Tzr).
-yeccgoto_props(16, Cat, Ss, Stack, T, Ts, Tzr) ->
- yeccpars2_18(18, Cat, Ss, Stack, T, Ts, Tzr);
-yeccgoto_props(20=_S, Cat, Ss, Stack, T, Ts, Tzr) ->
- yeccpars2_21(_S, Cat, Ss, Stack, T, Ts, Tzr).
+yeccgoto_props(19, Cat, Ss, Stack, T, Ts, Tzr) ->
+ yeccpars2_20(20, Cat, Ss, Stack, T, Ts, Tzr);
+yeccgoto_props(22=_S, Cat, Ss, Stack, T, Ts, Tzr) ->
+ yeccpars2_23(_S, Cat, Ss, Stack, T, Ts, Tzr).
-yeccgoto_value(3, Cat, Ss, Stack, T, Ts, Tzr) ->
- yeccpars2_4(4, Cat, Ss, Stack, T, Ts, Tzr);
-yeccgoto_value(9, Cat, Ss, Stack, T, Ts, Tzr) ->
- yeccpars2_9(10, Cat, Ss, Stack, T, Ts, Tzr);
-yeccgoto_value(10, Cat, Ss, Stack, T, Ts, Tzr) ->
- yeccpars2_15(15, Cat, Ss, Stack, T, Ts, Tzr);
+yeccgoto_value(0, Cat, Ss, Stack, T, Ts, Tzr) ->
+ yeccpars2_1(1, Cat, Ss, Stack, T, Ts, Tzr);
+yeccgoto_value(8, Cat, Ss, Stack, T, Ts, Tzr) ->
+ yeccpars2_10(10, Cat, Ss, Stack, T, Ts, Tzr);
yeccgoto_value(12, Cat, Ss, Stack, T, Ts, Tzr) ->
- yeccpars2_9(10, Cat, Ss, Stack, T, Ts, Tzr);
-yeccgoto_value(16, Cat, Ss, Stack, T, Ts, Tzr) ->
- yeccpars2_17(17, Cat, Ss, Stack, T, Ts, Tzr);
-yeccgoto_value(20, Cat, Ss, Stack, T, Ts, Tzr) ->
- yeccpars2_17(17, Cat, Ss, Stack, T, Ts, Tzr);
-yeccgoto_value(23=_S, Cat, Ss, Stack, T, Ts, Tzr) ->
- yeccpars2_24(_S, Cat, Ss, Stack, T, Ts, Tzr);
+ yeccpars2_12(13, Cat, Ss, Stack, T, Ts, Tzr);
+yeccgoto_value(13, Cat, Ss, Stack, T, Ts, Tzr) ->
+ yeccpars2_18(18, Cat, Ss, Stack, T, Ts, Tzr);
+yeccgoto_value(15, Cat, Ss, Stack, T, Ts, Tzr) ->
+ yeccpars2_12(13, Cat, Ss, Stack, T, Ts, Tzr);
+yeccgoto_value(19, Cat, Ss, Stack, T, Ts, Tzr) ->
+ yeccpars2_1(1, Cat, Ss, Stack, T, Ts, Tzr);
+yeccgoto_value(22, Cat, Ss, Stack, T, Ts, Tzr) ->
+ yeccpars2_1(1, Cat, Ss, Stack, T, Ts, Tzr);
yeccgoto_value(25, Cat, Ss, Stack, T, Ts, Tzr) ->
- yeccpars2_9(10, Cat, Ss, Stack, T, Ts, Tzr);
+ yeccpars2_12(13, Cat, Ss, Stack, T, Ts, Tzr);
yeccgoto_value(28, Cat, Ss, Stack, T, Ts, Tzr) ->
- yeccpars2_9(10, Cat, Ss, Stack, T, Ts, Tzr).
+ yeccpars2_12(13, Cat, Ss, Stack, T, Ts, Tzr);
+yeccgoto_value(33=_S, Cat, Ss, Stack, T, Ts, Tzr) ->
+ yeccpars2_34(_S, Cat, Ss, Stack, T, Ts, Tzr).
--compile({inline,{yeccpars2_2_,1}}).
--file("log4erl_parser.yrl", 5).
-yeccpars2_2_(__Stack0) ->
+-compile({inline,{yeccpars2_4_,1}}).
+-file("log4erl_parser.yrl", 8).
+yeccpars2_4_(__Stack0) ->
[__1 | __Stack] = __Stack0,
[begin
[ __1 ]
end | __Stack].
--compile({inline,{yeccpars2_5_,1}}).
--file("log4erl_parser.yrl", 24).
-yeccpars2_5_(__Stack0) ->
+-compile({inline,{yeccpars2_6_,1}}).
+-file("log4erl_parser.yrl", 27).
+yeccpars2_6_(__Stack0) ->
[__1 | __Stack] = __Stack0,
[begin
unwrap ( __1 )
end | __Stack].
-compile({inline,{yeccpars2_7_,1}}).
--file("log4erl_parser.yrl", 23).
+-file("log4erl_parser.yrl", 26).
yeccpars2_7_(__Stack0) ->
[__1 | __Stack] = __Stack0,
[begin
unwrap ( __1 )
end | __Stack].
--compile({inline,{yeccpars2_8_,1}}).
--file("log4erl_parser.yrl", 22).
-yeccpars2_8_(__Stack0) ->
+-compile({inline,{yeccpars2_9_,1}}).
+-file("log4erl_parser.yrl", 25).
+yeccpars2_9_(__Stack0) ->
[__1 | __Stack] = __Stack0,
[begin
unwrap ( __1 )
end | __Stack].
--compile({inline,{yeccpars2_12_,1}}).
--file("log4erl_parser.yrl", 12).
-yeccpars2_12_(__Stack0) ->
+-compile({inline,{yeccpars2_15_,1}}).
+-file("log4erl_parser.yrl", 15).
+yeccpars2_15_(__Stack0) ->
[__1 | __Stack] = __Stack0,
[begin
[ __1 ]
end | __Stack].
--compile({inline,{yeccpars2_13_,1}}).
--file("log4erl_parser.yrl", 13).
-yeccpars2_13_(__Stack0) ->
+-compile({inline,{yeccpars2_16_,1}}).
+-file("log4erl_parser.yrl", 16).
+yeccpars2_16_(__Stack0) ->
[__2,__1 | __Stack] = __Stack0,
[begin
[ __1 ] ++ __2
end | __Stack].
--compile({inline,{yeccpars2_14_,1}}).
--file("log4erl_parser.yrl", 9).
-yeccpars2_14_(__Stack0) ->
+-compile({inline,{yeccpars2_17_,1}}).
+-file("log4erl_parser.yrl", 12).
+yeccpars2_17_(__Stack0) ->
[__4,__3,__2,__1 | __Stack] = __Stack0,
[begin
{ default_logger , __3 }
end | __Stack].
--compile({inline,{yeccpars2_19_,1}}).
--file("log4erl_parser.yrl", 17).
-yeccpars2_19_(__Stack0) ->
+-compile({inline,{yeccpars2_21_,1}}).
+-file("log4erl_parser.yrl", 20).
+yeccpars2_21_(__Stack0) ->
[__1 | __Stack] = __Stack0,
[begin
[ __1 ]
end | __Stack].
--compile({inline,{yeccpars2_21_,1}}).
--file("log4erl_parser.yrl", 18).
-yeccpars2_21_(__Stack0) ->
+-compile({inline,{yeccpars2_23_,1}}).
+-file("log4erl_parser.yrl", 21).
+yeccpars2_23_(__Stack0) ->
[__3,__2,__1 | __Stack] = __Stack0,
[begin
[ __1 ] ++ __3
end | __Stack].
--compile({inline,{yeccpars2_22_,1}}).
--file("log4erl_parser.yrl", 15).
-yeccpars2_22_(__Stack0) ->
- [__5,__4,__3,__2,__1 | __Stack] = __Stack0,
- [begin
- { appender , __1 , __2 , __4 }
- end | __Stack].
-
-compile({inline,{yeccpars2_24_,1}}).
--file("log4erl_parser.yrl", 20).
+-file("log4erl_parser.yrl", 18).
yeccpars2_24_(__Stack0) ->
- [__3,__2,__1 | __Stack] = __Stack0,
+ [__5,__4,__3,__2,__1 | __Stack] = __Stack0,
[begin
- { __1 , __3 }
+ { appender , __1 , __2 , __4 }
end | __Stack].
-compile({inline,{yeccpars2_27_,1}}).
--file("log4erl_parser.yrl", 10).
+-file("log4erl_parser.yrl", 13).
yeccpars2_27_(__Stack0) ->
[__5,__4,__3,__2,__1 | __Stack] = __Stack0,
[begin
@@ -508,7 +530,7 @@ yeccpars2_27_(__Stack0) ->
end | __Stack].
-compile({inline,{yeccpars2_30_,1}}).
--file("log4erl_parser.yrl", 8).
+-file("log4erl_parser.yrl", 11).
yeccpars2_30_(__Stack0) ->
[__5,__4,__3,__2,__1 | __Stack] = __Stack0,
[begin
@@ -516,12 +538,28 @@ yeccpars2_30_(__Stack0) ->
end | __Stack].
-compile({inline,{yeccpars2_31_,1}}).
--file("log4erl_parser.yrl", 6).
+-file("log4erl_parser.yrl", 9).
yeccpars2_31_(__Stack0) ->
[__2,__1 | __Stack] = __Stack0,
[begin
[ __1 ] ++ __2
end | __Stack].
+-compile({inline,{yeccpars2_32_,1}}).
+-file("log4erl_parser.yrl", 6).
+yeccpars2_32_(__Stack0) ->
+ [__2,__1 | __Stack] = __Stack0,
+ [begin
+ [ __1 ] ++ __2
+ end | __Stack].
--file("log4erl_parser.yrl", 33).
+-compile({inline,{yeccpars2_34_,1}}).
+-file("log4erl_parser.yrl", 23).
+yeccpars2_34_(__Stack0) ->
+ [__3,__2,__1 | __Stack] = __Stack0,
+ [begin
+ { __1 , __3 }
+ end | __Stack].
+
+
+-file("log4erl_parser.yrl", 36).
View
9 src/log4erl_parser.yrl
@@ -1,10 +1,13 @@
-Nonterminals loggers logger appenders appender props prop value.
+Nonterminals cutoff_level loggers logger appenders appender props prop value.
-% 'loger' is missing 'e' not to be confused with Nonterminals
+% 'loger' is missing 'g' not to be confused with Nonterminals
% check 'log4erl_conf.xrl'
Terminals '{' '}' ',' '=' 'loger' 'default' 'integer' 'val' 'atom'.
-Rootsymbol loggers.
+Rootsymbol cutoff_level.
+
+cutoff_level -> loggers : '$1'.
+cutoff_level -> prop loggers : ['$1'] ++ '$2'.
loggers -> logger : ['$1'].
loggers -> logger loggers : ['$1'] ++ '$2'.
View
18 src/log4erl_sup.erl
@@ -16,7 +16,7 @@
-export([init/1]).
start_link(Default_logger) ->
- R = supervisor:start_link({local, ?MODULE}, ?MODULE, [Default_logger]),
+ R = supervisor:start_link({local, ?MODULE}, ?MODULE, []),
%log4erl:start_link(Default_logger),
add_logger(Default_logger),
?LOG2("Result in supervisor is ~p~n",[R]),
@@ -50,23 +50,23 @@ add_logger(Name) when is_list(Name) ->
%%======================================
%% supervisor callback functions
%%======================================
-init([Default_logger]) ->
+init([]) ->
?LOG("Starting supervisor~n"),
%% No children to be added yet.
%% The default has to be added from log4erl
% start log4erl gen_server
- _Child = {log4erl_p,
- {log4erl, start_link ,[Default_logger]},
- permanent,
- 10000,
- worker,
- [log4erl]},
+ %% _Child = {log4erl_p,
+%% {log4erl, start_link ,[Default_logger]},
+%% permanent,
+%% 10000,
+%% worker,
+%% [log4erl]},
{ok,
{
{one_for_one,3,10},
- [_Child]
+ []
%[]
}
}.
View
7 src/log_filter.erl
@@ -0,0 +1,7 @@
+%% Author: David Dossot <david@dossot.net>
+%% Created: Oct 25, 2009
+-module(log_filter).
+
+-export([cutoff_level/0]).
+
+cutoff_level() -> debug.
View
28 src/log_filter_codegen.erl
@@ -0,0 +1,28 @@
+%% Author: David Dossot <david@dossot.net>
+%% Created: Oct 25, 2009
+%% Description: Generates log_filter based on the log4erl cutoff level.
+-module(log_filter_codegen).
+
+-export([reset/0, set_cutoff_level/1]).
+
+reset() ->
+ set_cutoff_level(debug).
+
+set_cutoff_level(CutoffLevel) ->
+ LogFilterMod = log_filter_mod(CutoffLevel),
+ compile_and_load_abstract_form(LogFilterMod).
+
+%% Private functions
+compile_and_load_abstract_form(AbsForm) ->
+ CompRes = compile:forms(AbsForm),
+ {ok, Mod, Code} = CompRes,
+ code:purge(Mod),
+ code:delete(Mod),
+ {module, _} = load_module(Mod, Code),
+ ok.
+
+log_filter_mod(CutoffLevel) ->
+ [{attribute,1,module,log_filter},
+ {attribute,3,export,[{cutoff_level,0}]},
+ {function,5,cutoff_level,0,[{clause,5,[],[],[{atom,5,CutoffLevel}]}]},
+ {eof,5}].
View
28 src/log_manager.erl
@@ -33,37 +33,9 @@ change_log_level(Logger, Level) ->
change_level(Logger, Appender, Level) ->
call_appender(Logger, Appender, {change_level, Level}).
-%% try
-%% Apps = gen_event:which_handlers(Logger)
-%% ?LOG2("log_manager:change_format/3 get apps ~p~n",[Apps]),
-%% case lists:filter(fun({_,X}) -> X =:= Appender end, Apps) of
-%% [] ->
-%% {error, no_appender_found};
-%% [Apps1] ->
-%% ?LOG2("get apps: ~p~n",[Apps1]),
-%% gen_event:call(Logger, Apps1, {change_level, Level})
-%% end
-%% catch
-%% exit:noproc ->
-%% {error, no_such_logger}
-%% end.
change_format(Logger, Appender, Format) ->
call_appender(Logger, Appender, {change_format, Format}).
-%% try
-%% Apps = gen_event:which_handlers(Logger),
-%% ?LOG2("log_manager:change_format/3 get apps ~p~n",[Apps]),
-%% case lists:filter(fun({_,X}) -> X =:= Appender end, Apps) of
-%% [] ->
-%% {error, no_appender_found};
-%% [Apps1] ->
-%% ?LOG2("get apps: ~p~n",[Apps1]),
-%% gen_event:call(Logger, Apps1, {change_format, Format})
-%% end
-%% catch
-%% exit:noproc ->
-%% {error, no_such_logger}
-%% end.
%%--------------------------------------------------------------------
%% Logger API functions
View
25 src/syslog_appender.erl
@@ -82,8 +82,7 @@ code_change(_OldVsn, State, _Extra) ->
do_log(#log{level = L} = Log, #syslog_appender{level=Level} = State) ->
%% Syslog levels are a little bit differnt
- ToLog = to_log(L, Level),
- case ToLog of
+ case should_log(L, Level) of
true ->
Pid = State#syslog_appender.socket,
Host = State#syslog_appender.host,
@@ -92,8 +91,8 @@ do_log(#log{level = L} = Log, #syslog_appender{level=Level} = State) ->
Fac = State#syslog_appender.facility,
Msg = log_formatter:format(Log, Format),
- L2 = level(L),
- do_send(Pid, Host, Port, {Fac, L2, Msg});
+ Who = node(),
+ do_send(Pid, Host, Port, {Who, Fac, L, Msg});
false ->
ok
end.
@@ -107,7 +106,6 @@ do_log(#log{level = L} = Log, #syslog_appender{level=Level} = State) ->
%% Convenient routine for specifying levels.
%% modified by ahmed al-issaei
-level(all) -> 0; % to allow 'all' in conf parameters for level
level(emergency) -> 0; % system is unusable
level(emerg) -> 0; % shortcut for emergency
level(alert) -> 1; % action must be taken immediately
@@ -120,6 +118,7 @@ level(warn) -> 4; % shortcut for warning
level(notice) -> 5; % normal but significant condition
level(info) -> 6; % informational
level(debug) -> 7; % debug-level messages
+level(all) -> 7; % to allow 'all' in conf parameters for level
level(_) -> 1. % anything else is alert
%% Convenient routine for specifying facility codes
@@ -153,12 +152,11 @@ facility(_) -> facility(user). % anything else is user
%% priorities/facilities are encoded into a single 32-bit
%% quantity, where the bottom 3 bits are the priority (0-7)
%% and the top 28 bits are the facility (0-big number).
-do_send(S,Host,Port,{Who,Level,Msg}) ->
- Packet = "<" ++ i2l(Level) ++ "> " ++ a2l(Who) ++ ": " ++ Msg ++ "\n",
- gen_udp:send(S,Host,Port,Packet);
-do_send(S,Host,Port,{Facil,Who,Level,Msg}) ->
- Packet = "<" ++ i2l(Facil bor Level) ++ "> " ++ a2l(Who) ++ ": " ++ Msg ++ "\n",
- gen_udp:send(S,Host,Port,Packet).
+do_send(S,Host,Port,{Who,Facility,Level,Msg})
+ when is_atom(Who), is_atom(Facility), is_atom(Level) ->
+ Type = (facility(Facility) bor level(Level)),
+ Packet = "<" ++ i2l(Type) ++ "> " ++ a2l(Who) ++ ": " ++ Msg ++ "\n",
+ gen_udp:send(S,Host,Port,lists:flatten(Packet)).
i2l(Int) when is_integer(Int) ->
integer_to_list(Int);
@@ -170,5 +168,6 @@ a2l(Atom) when is_atom(Atom) ->
a2l(Atom) ->
Atom.
-to_log(Cur, Level) ->
- level(Cur) > level(Level).
+%% Log4erl uses decreasing values for priority
+should_log(Cur, Level) when is_atom(Cur), is_atom(Level) ->
+ level(Cur) =< level(Level).
Please sign in to comment.
Something went wrong with that request. Please try again.