Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Bugfix: accept UTC.

  • Loading branch information...
commit b956218601c838ab156314330ba937a8fbbf3105 1 parent 0850229
@vjache authored
View
4 dev.config
@@ -16,8 +16,8 @@
{archive_after, {7, day}}, % Recorder will move & zip logs older than this
% (if not specified explicitely then archive
% directory will be './errlogs/archive' i.e.
- % relative to <'dir' property value>+/+'archive')
- {locate_em, error_logger} % Locator will seek event managers registered
+ % relative to <'dir' property value> +/+'archive')
+ {locate_em, {local,error_logger}} % Locator will seek event managers registered
% with this name on each visible node in a cluster
]}
]}
View
4 include/types.hrl
@@ -35,4 +35,6 @@
[{ InstanceName :: atom(), % Instance section
[instance_config_item()]}] % Instance specific properties
}
- ]} .
+ ]} .
+
+-define(IS_TIMESTAMP(T), (is_integer(element(1,T)) andalso is_integer(element(2,T)) andalso is_integer(element(3,T)))).
View
2  src/logmachine.app.src
@@ -1,7 +1,7 @@
%% -*- mode: erlang; -*-
{application, logmachine,
[{description, "An Erlang Log Machine"},
- {vsn, "0.0.11"},
+ {vsn, "0.0.12"},
{registered, []},
{build_dependencies, []},
{env, []},
View
8 src/logmachine.erl
@@ -93,10 +93,10 @@ subscribe(InstanceName, FromTimestamp, SubPid, Marker, MatchSpec) ->
%%-------------------------------------------------------------------------------
-spec get_zlist(InstanceName :: atom(),
FromTimestamp :: timestamp()) -> zlists:zlist(history_entry()).
-get_zlist(InstanceName, FromTimestamp) ->
+get_zlist(InstanceName, FromTimestamp) when ?IS_TIMESTAMP(FromTimestamp) ->
case logmachine_cache_srv:get_interval(InstanceName) of
% If fits into RAM
- {From, _To} when From =< FromTimestamp ->
+ {From, _To} when From =< FromTimestamp, ?IS_TIMESTAMP(From) ->
logmachine_cache_srv:get_history(InstanceName, FromTimestamp);
% Otherwise read from disk log
_ ->
@@ -108,7 +108,9 @@ get_zlist(InstanceName, FromTimestamp) ->
% Exclude last element
zlists:dropwhile(fun(E1) -> E==E1 end, ZList)
end)
- end.
+ end;
+get_zlist(InstanceName, {{_,_,_},{_,_,_},_}=FromTimestamp) ->
+ get_zlist(InstanceName, logmachine_util:utc_to_now(FromTimestamp)).
%%-------------------------------------------------------------------------------
%% @doc
View
5 src/logmachine_recorder_srv.erl
@@ -83,11 +83,10 @@ get_history(InstanceName, FromTimestamp, ToTimestamp) ->
From :: timestamp()) -> zlists:zlist(history_entry()) .
get_history(InstanceName, From) ->
LogDir=get_data_dir(InstanceName),
- FromLT=to_long_timestamp(From),
- LogFilesToScan=get_log_files(InstanceName, FromLT),
+ LogFilesToScan=get_log_files(InstanceName, From),
%% ?ECHO({"LOGS_TO_SCAN",zlists:expand(LogFilesToScan)}),
zlists:dropwhile(
- fun({T,_})-> to_long_timestamp(T) < FromLT end,
+ fun({T,_})-> T < From end,
zlists:generate(
LogFilesToScan,
fun(Filename)->
View
16 src/logmachine_util.erl
@@ -27,11 +27,19 @@
%%
%% Exported Functions
%%
--export([make_name/1, to_millis/1, now_to_millis/1,millis_to_now/1, send_after/2, ensure_dir/1]).
+-export([make_name/1,
+ to_millis/1,
+ now_to_millis/1,
+ millis_to_now/1,
+ send_after/2,
+ ensure_dir/1,
+ utc_to_ms1970/1,
+ utc_to_now/1]).
%%
%% API Functions
%%
+-define(SEC1970, 62167219200).
ensure_dir(Dir) ->
case filelib:ensure_dir(filename:join(Dir, "fake")) of
@@ -68,6 +76,12 @@ to_millis({N,hms}) ->
send_after(Period, Message) ->
{ok,_}=timer:send_after(to_millis(Period), Message).
+utc_to_ms1970({{Year,Month,Day}, {Hour,Min,Sec}, Mls}) ->
+ (calendar:datetime_to_gregorian_seconds({{Year,Month,Day},{Hour,Min,Sec}}) - ?SEC1970)*1000 + Mls.
+
+utc_to_now(UTC) ->
+ millis_to_now(utc_to_ms1970(UTC)).
+
%%
%% Local Functions
%%
Please sign in to comment.
Something went wrong with that request. Please try again.