Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ldclient.erl
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ ensure_context(#{kind := _Kind} = ContextOrContext) -> ContextOrContext;
ensure_context(UserOrContext) ->
case maps:is_key(key, UserOrContext) of
%% We allow legacy users to have an empty key, but we log it.
false -> error_logger:warning_msg("Context key is blank. Flag evaluation will proceed, but the context will not be stored in Launchdarkly");
false -> logger:warning("Context key is blank. Flag evaluation will proceed, but the context will not be stored in Launchdarkly", #{domain => [ldclient]});
true -> ok
end,
ldclient_context:new_from_user(UserOrContext).
Expand Down
8 changes: 4 additions & 4 deletions src/ldclient_config.erl
Original file line number Diff line number Diff line change
Expand Up @@ -388,8 +388,8 @@ set_valid_tag(Key, Value, MapOrUndefined) ->
false -> #{Key => Value}
end;
false ->
error_logger:warning_msg("The application ~p was invalid. Must only contain letters, numbers, ., _ or -,"
" be 64 characters or less, and cannot be an empty string.", [Key]),
logger:warning("The application ~p was invalid. Must only contain letters, numbers, ., _ or -,"
" be 64 characters or less, and cannot be an empty string.", [Key], #{domain => [ldclient]}),
MapOrUndefined
end.

Expand Down Expand Up @@ -445,10 +445,10 @@ tls_base_options() ->
tls_basic_options(true) ->
tls_basic_linux_options();
tls_basic_options(false) ->
error_logger:warning_msg("TLS options are falling back to using the certifi store.
logger:warning("TLS options are falling back to using the certifi store.
This means the OS certificate store was not in the default location (/etc/ssl/certs/ca-certificates.crt).
Please specify a custom location. You can use tls_ca_certfile_options, or fully specify the tls_options.
You may see this warning in development on Mac/Windows."),
You may see this warning in development on Mac/Windows.", #{domain => [ldclient]}),
tls_basic_certifi_options().

-spec validate_tag_value(Value :: binary() | undefined) -> boolean().
Expand Down
24 changes: 12 additions & 12 deletions src/ldclient_eval.erl
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ flag_key_for_context(_Tag, _FlagKey, _Context, DefaultValue, offline, _) ->
flag_key_for_context(_Tag, _FlagKey, _Context, DefaultValue, _, not_initialized) ->
{{null, DefaultValue, {error, client_not_ready}}, []};
flag_key_for_context(Tag, FlagKey, Context, DefaultValue, online, store_initialized) ->
error_logger:warning_msg("Variation called before LaunchDarkly client initialization completed - using last known values from feature store."),
logger:warning("Variation called before LaunchDarkly client initialization completed - using last known values from feature store.", #{domain => [ldclient]}),
FeatureStore = ldclient_config:get_value(Tag, feature_store),
FlagRecs = FeatureStore:get(Tag, features, FlagKey),
flag_recs_for_context(FlagKey, FlagRecs, Context, FeatureStore, Tag, DefaultValue);
Expand Down Expand Up @@ -145,7 +145,7 @@ all_flags_state(_Context, _Options, _Tag, offline, _) ->
all_flags_state(_Context, _Options, _Tag, _, not_initialized) ->
#{<<"$valid">> => false, <<"$flagsState">> => #{}};
all_flags_state(Context, #{with_reasons := WithReason} = _Options, Tag, Offline, store_initialized) ->
error_logger:warning_msg("Called allFlagsState before client initialization; using last known values from data store."),
logger:warning("Called allFlagsState before client initialization; using last known values from data store.", #{domain => [ldclient]}),
all_flags_state(Context, #{with_reasons := WithReason} = _Options, Tag, Offline, initialized);
all_flags_state(Context, #{with_reasons := WithReason} = Options, Tag, _, initialized) ->
FeatureStore = ldclient_config:get_value(Tag, feature_store),
Expand Down Expand Up @@ -246,7 +246,7 @@ all_flags_eval(_Context, _Tag, offline, _) ->
all_flags_eval(_Context, _Tag, _, not_initialized) ->
#{flag_values => #{}};
all_flags_eval(Context, Tag, Offline, store_initialized) ->
error_logger:warning_msg("Called allFlagsState before client initialization; using last known values from data store."),
logger:warning("Called allFlagsState before client initialization; using last known values from data store.", #{domain => [ldclient]}),
all_flags_eval(Context, Tag, Offline, initialized);
all_flags_eval(Context, Tag, online, initialized) ->
FeatureStore = ldclient_config:get_value(Tag, feature_store),
Expand Down Expand Up @@ -309,13 +309,13 @@ get_initialization_state(Tag, false) ->
) -> result().
flag_recs_for_context(FlagKey, [], Context, _FeatureStore, _Tag, DefaultValue) ->
% Flag not found
error_logger:warning_msg("Unknown feature flag ~p; returning default value", [FlagKey]),
logger:warning("Unknown feature flag ~p; returning default value", [FlagKey], #{domain => [ldclient]}),
Reason = {error, flag_not_found},
Events = [ldclient_event:new_for_unknown_flag(FlagKey, Context, DefaultValue, Reason)],
{{null, DefaultValue, Reason}, Events};
flag_recs_for_context(FlagKey, [{FlagKey, #{deleted := true}} | _], Context, _FeatureStore, _Tag, DefaultValue) ->
% Flag found, but it's deleted
error_logger:warning_msg("Unknown feature flag ~p; returning default value", [FlagKey]),
logger:warning("Unknown feature flag ~p; returning default value", [FlagKey], #{domain => [ldclient]}),
Reason = {error, flag_not_found},
Events = [ldclient_event:new_for_unknown_flag(FlagKey, Context, DefaultValue, Reason)],
{{null, DefaultValue, Reason}, Events};
Expand Down Expand Up @@ -394,8 +394,8 @@ check_prerequisites(
) ->
case lists:member(PrerequisiteKey, VisitedFlags) of
true ->
error_logger:error_msg("Prerequisite of ~p causing a circular reference."
" This is probably a temporary condition due to an incomplete update.", [FlagKey]),
logger:error("Prerequisite of ~p causing a circular reference."
" This is probably a temporary condition due to an incomplete update.", [FlagKey], #{domain => [ldclient]}),
flag_for_context_prerequisites({malformed_flag, {error, malformed_flag}},
Flag, Context, FeatureStore, Tag, DefaultValue, Events);
false ->
Expand All @@ -420,7 +420,7 @@ check_prerequisites(
check_prerequisite_recs([], PrerequisiteKey, _Variation, _Prerequisites, #{key := FlagKey} = Flag,
Context, FeatureStore, Tag, DefaultValue, Events, _VisitedFlags) ->
% Short circuit if prerequisite flag is not found
error_logger:error_msg("Could not retrieve prerequisite flag ~p when evaluating ~p", [PrerequisiteKey, FlagKey]),
logger:error("Could not retrieve prerequisite flag ~p when evaluating ~p", [PrerequisiteKey, FlagKey], #{domain => [ldclient]}),
flag_for_context_prerequisites({fail, {prerequisite_failed, [PrerequisiteKey]}}, Flag, Context,
FeatureStore, Tag, DefaultValue, Events);
check_prerequisite_recs([{PrerequisiteKey, PrerequisiteFlag} | _], PrerequisiteKey, Variation, Prerequisites, Flag,
Expand Down Expand Up @@ -526,7 +526,7 @@ check_rules([Rule | Rest], Flag, Context, FeatureStore, Tag, DefaultValue, Event
check_rule_result({Result, Rule, Index}, Rest, Flag, Context, FeatureStore, Tag, DefaultValue, Events).

check_rule_result({malformed_flag, _Rule, _Index}, _Rest, #{key := FlagKey} = _Flag, _Context, _FeatureStore, _Tag, DefaultValue, _Events) ->
error_logger:warning_msg("Data inconsistency in feature flag ~p: clause was malformed", [FlagKey]),
logger:warning("Data inconsistency in feature flag ~p: clause was malformed", [FlagKey], #{domain => [ldclient]}),
Reason = {error, malformed_flag},
{{null, DefaultValue, Reason}, []};
check_rule_result({no_match, _Rule, Index}, Rest, Flag, Context, FeatureStore, Tag, DefaultValue, Events) ->
Expand All @@ -546,19 +546,19 @@ flag_for_context_variation_or_rollout(Variation, Reason, Flag, _Context, Default
flag_for_context_variation_or_rollout(Rollout, Reason, #{key := FlagKey} = Flag, Context, DefaultValue, Events) when is_map(Rollout) ->
case ldclient_rollout:rollout_context(Rollout, Flag, Context) of
malformed_flag ->
error_logger:warning_msg("Data inconsistency in feature flag ~p: rollout was malformed", [FlagKey]),
logger:warning("Data inconsistency in feature flag ~p: rollout was malformed", [FlagKey], #{domain => [ldclient]}),
{{null, DefaultValue, {error, malformed_flag}}, []};
{Result, InExperiment} ->
UpdatedReason = experimentize_reason(InExperiment, Reason),
flag_for_context_rollout_result(Result, UpdatedReason, Flag, DefaultValue, Events)
end;
flag_for_context_variation_or_rollout(null, _Reason, #{key := FlagKey}, _Context, DefaultValue, Events) ->
error_logger:warning_msg("Data inconsistency in feature flag ~p: rule object with no variation or rollout", [FlagKey]),
logger:warning("Data inconsistency in feature flag ~p: rule object with no variation or rollout", [FlagKey], #{domain => [ldclient]}),
Reason = {error, malformed_flag},
{{null, DefaultValue, Reason}, Events}.

flag_for_context_rollout_result(null, _Reason, #{key := FlagKey}, DefaultValue, Events) ->
error_logger:warning_msg("Data inconsistency in feature flag ~p: variation/rollout object with no variation or rollout", [FlagKey]),
logger:warning("Data inconsistency in feature flag ~p: variation/rollout object with no variation or rollout", [FlagKey], #{domain => [ldclient]}),
Reason = {error, malformed_flag},
{{null, DefaultValue, Reason}, Events};

Expand Down
4 changes: 2 additions & 2 deletions src/ldclient_event_process_server.erl
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ get_last_server_time(Tag) ->
{ok, Pid :: pid()} | ignore | {error, Reason :: term()}.
start_link(Tag) ->
ServerName = get_local_reg_name(Tag),
error_logger:info_msg("Starting event processor for ~p with name ~p", [Tag, ServerName]),
logger:info("Starting event processor for ~p with name ~p", [Tag, ServerName], #{domain => [ldclient]}),
gen_server:start_link({local, ServerName}, ?MODULE, [Tag], []).

-spec init(Args :: term()) ->
Expand Down Expand Up @@ -126,7 +126,7 @@ handle_cast({send_events, Events, SummaryEvent},
erlang:send_after(1000, self(), {send, OutputEvents, PayloadId}),
State;
{error, permanent, Reason} ->
error_logger:error_msg("Permanent error sending events ~p", [Reason]),
logger:error("Permanent error sending events ~p", [Reason], #{domain => [ldclient]}),
State
end,
{noreply, NewState};
Expand Down
6 changes: 3 additions & 3 deletions src/ldclient_event_server.erl
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ flush(Tag) when is_atom(Tag) ->
{ok, Pid :: pid()} | ignore | {error, Reason :: term()}.
start_link(Tag) ->
ServerName = get_local_reg_name(Tag),
error_logger:info_msg("Starting event storage server for ~p with name ~p", [Tag, ServerName]),
logger:info("Starting event storage server for ~p with name ~p", [Tag, ServerName], #{domain => [ldclient]}),
gen_server:start_link({local, ServerName}, ?MODULE, [Tag], []).

-spec init(Args :: term()) ->
Expand Down Expand Up @@ -152,7 +152,7 @@ handle_info(_Info, State) ->
-spec terminate(Reason :: (normal | shutdown | {shutdown, term()} | term()),
State :: state()) -> term().
terminate(Reason, #{timer_ref := TimerRef} = _State) ->
error_logger:info_msg("Terminating event service, reason: ~p", [Reason]),
logger:info("Terminating event service, reason: ~p", [Reason], #{domain => [ldclient]}),
_ = erlang:cancel_timer(TimerRef),
ok;
terminate(_Reason, _State) ->
Expand Down Expand Up @@ -195,7 +195,7 @@ add_event(Tag, #{type := custom, context := Context, timestamp := Timestamp} = E
add_raw_event(Event, Events, Capacity) when length(Events) < Capacity ->
[Event|Events];
add_raw_event(_, Events, _) ->
error_logger:warning_msg("Exceeded event queue capacity. Increase capacity to avoid dropping events."),
logger:warning("Exceeded event queue capacity. Increase capacity to avoid dropping events.", #{domain => [ldclient]}),
Events.

-spec add_feature_request_event(ldclient_event:event(), summary_event()) ->
Expand Down
2 changes: 1 addition & 1 deletion src/ldclient_event_sup.erl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
-spec start_link(SupName :: atom(), Tag :: atom()) ->
{ok, Pid :: pid()} | ignore | {error, Reason :: term()}.
start_link(SupName, Tag) ->
error_logger:info_msg("Starting event supervisor for ~p with name ~p", [Tag, SupName]),
logger:info("Starting event supervisor for ~p with name ~p", [Tag, SupName], #{domain => [ldclient]}),
supervisor:start_link({local, SupName}, ?MODULE, [Tag]).

-spec init(Args :: term()) ->
Expand Down
2 changes: 1 addition & 1 deletion src/ldclient_instance_sup.erl
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ child_spec(Id, Args) ->
) ->
{ok, Pid :: pid()} | ignore | {error, Reason :: term()}.
start_link(SupName, UpdateSupName, UpdateWorkerModule, EventSupName, Tag) ->
error_logger:info_msg("Starting instance supervisor for ~p with name ~p", [Tag, SupName]),
logger:info("Starting instance supervisor for ~p with name ~p", [Tag, SupName], #{domain => [ldclient]}),
supervisor:start_link({local, SupName}, ?MODULE, [UpdateSupName, UpdateWorkerModule, EventSupName, Tag]).

-spec init(Args :: term()) ->
Expand Down
2 changes: 1 addition & 1 deletion src/ldclient_rollout.erl
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ parse_rollout_kind(<<"experiment">>) -> experiment;
parse_rollout_kind(<<"rollout">>) -> rollout;
parse_rollout_kind(Kind) ->
%% If we are not familiar with this kind, then log it and default to rollout.
error_logger:warning_msg("Unrecognized rollout type: ~p", [Kind]),
logger:warning("Unrecognized rollout type: ~p", [Kind], #{domain => [ldclient]}),
rollout.

-spec rollout_context(
Expand Down
2 changes: 1 addition & 1 deletion src/ldclient_storage_cache_server.erl
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
%%===================================================================

start_link(WorkerRegName, Tag) ->
error_logger:info_msg("Starting map server with name ~p", [WorkerRegName]),
logger:info("Starting map server with name ~p", [WorkerRegName], #{domain => [ldclient]}),
gen_server:start_link({local, WorkerRegName}, ?MODULE, [Tag], []).

init([Tag]) ->
Expand Down
2 changes: 1 addition & 1 deletion src/ldclient_storage_ets_server.erl
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
%%===================================================================

start_link(WorkerRegName, Tag) ->
error_logger:info_msg("Starting ets server with name ~p", [WorkerRegName]),
logger:info("Starting ets server with name ~p", [WorkerRegName], #{domain => [ldclient]}),
gen_server:start_link({local, WorkerRegName}, ?MODULE, [Tag], []).

init([Tag]) ->
Expand Down
2 changes: 1 addition & 1 deletion src/ldclient_storage_map_server.erl
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
%%===================================================================

start_link(WorkerRegName, Tag) ->
error_logger:info_msg("Starting map server with name ~p", [WorkerRegName]),
logger:info("Starting map server with name ~p", [WorkerRegName], #{domain => [ldclient]}),
gen_server:start_link({local, WorkerRegName}, ?MODULE, [Tag], []).

init([Tag]) ->
Expand Down
22 changes: 11 additions & 11 deletions src/ldclient_storage_redis_server.erl
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ tag => atom()
%%===================================================================

start_link(WorkerRegName, Tag) ->
error_logger:info_msg("Starting redis server with name ~p", [WorkerRegName]),
logger:info("Starting redis server with name ~p", [WorkerRegName], #{domain => [ldclient]}),
gen_server:start_link({local, WorkerRegName}, ?MODULE, [Tag], []).

-spec set_tls_options(Options :: list(), TlsOptions :: list()) -> OutOptions :: list().
Expand Down Expand Up @@ -211,7 +211,7 @@ create_bucket(false, Bucket, Client, Prefix, Buckets) ->
{ok, _} ->
{ok, [Bucket | Buckets]};
{error, Reason} ->
error_logger:error_msg("Redis connection error during create_bucket for ~p: ~p", [Bucket, Reason]),
logger:error("Redis connection error during create_bucket for ~p: ~p", [Bucket, Reason], #{domain => [ldclient]}),
{ok, [Bucket | Buckets]}
end.

Expand All @@ -231,7 +231,7 @@ empty_bucket(true, Bucket, Client, Prefix) ->
{ok, _} = create_bucket(false, Bucket, Client, Prefix, []),
ok;
{error, Reason} ->
error_logger:error_msg("Redis connection error during empty_bucket for ~p: ~p", [Bucket, Reason]),
logger:error("Redis connection error during empty_bucket for ~p: ~p", [Bucket, Reason], #{domain => [ldclient]}),
ok
end.

Expand All @@ -253,7 +253,7 @@ all_items(true, Bucket, Client, Prefix) ->
not lists:member(Elem, NullFilter) end, Values), %This removes the initial null key and value
pairs(NewValues, Bucket);
{error, Reason} ->
error_logger:error_msg("Redis error listing all items in bucket ~p: ~s", [Bucket, format_error(Reason)]),
logger:error("Redis error listing all items in bucket ~p: ~s", [Bucket, format_error(Reason)], #{domain => [ldclient]}),
[]
end.

Expand Down Expand Up @@ -296,7 +296,7 @@ lookup_key(true, Key, Bucket, Client, Prefix) ->
end
end;
{error, Reason} ->
error_logger:error_msg("Redis error looking up key ~p in bucket ~p: ~s", [Key, Bucket, format_error(Reason)]),
logger:error("Redis error looking up key ~p in bucket ~p: ~s", [Key, Bucket, format_error(Reason)], #{domain => [ldclient]}),
[]
end.

Expand All @@ -317,18 +317,18 @@ upsert_items(true, Items, Bucket, Client, Prefix) ->
case eredis:q(Client, ["HSET", bucket_name(Prefix, Bucket), K, jsx:encode(V)]) of
{ok, _} -> ok;
{error, Reason} ->
error_logger:error_msg("Redis connection error during HSET for ~p key ~p: ~p", [Bucket, K, Reason]),
logger:error("Redis connection error during HSET for ~p key ~p: ~p", [Bucket, K, Reason], #{domain => [ldclient]}),
ok
end
end, ok, Items),
case eredis:q(Client, ["UNWATCH"]) of
{ok, <<"OK">>} -> Result;
{error, Reason} ->
error_logger:error_msg("Redis connection error during UNWATCH for ~p: ~p", [Bucket, Reason]),
logger:error("Redis connection error during UNWATCH for ~p: ~p", [Bucket, Reason], #{domain => [ldclient]}),
ok
end;
{error, Reason} ->
error_logger:error_msg("Redis connection error during WATCH for ~p: ~p", [Bucket, Reason]),
logger:error("Redis connection error during WATCH for ~p: ~p", [Bucket, Reason], #{domain => [ldclient]}),
ok
end.

Expand Down Expand Up @@ -360,7 +360,7 @@ delete_key(true, Key, Bucket, Client, Prefix) ->
case eredis:q(Client, ["HDEL", bucket_name(Prefix, Bucket), Key]) of
{ok, _} -> ok;
{error, Reason} ->
error_logger:error_msg("Redis connection error during delete_key for ~p key ~p: ~p", [Bucket, Key, Reason]),
logger:error("Redis connection error during delete_key for ~p key ~p: ~p", [Bucket, Key, Reason], #{domain => [ldclient]}),
ok
end.

Expand All @@ -380,7 +380,7 @@ set_init(Client, Prefix) ->
case eredis:q(Client, ["SET", lists:concat([Prefix, ":$inited"]), ""]) of
{ok, _} -> ok;
{error, Reason} ->
error_logger:error_msg("Redis connection error during set_init: ~p", [Reason]),
logger:error("Redis connection error during set_init: ~p", [Reason], #{domain => [ldclient]}),
ok
end.

Expand All @@ -393,6 +393,6 @@ get_init(Client, Prefix) ->
_ -> true
end;
{error, Reason} ->
error_logger:error_msg("Redis error getting init flag: ~s", [format_error(Reason)]),
logger:error("Redis error getting init flag: ~s", [format_error(Reason)], #{domain => [ldclient]}),
false
end.
2 changes: 1 addition & 1 deletion src/ldclient_testdata.erl
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ handle_info(_Info, State) ->
-spec terminate(Reason :: (normal | shutdown | {shutdown, term()} | term()),
State :: state()) -> term().
terminate(Reason, _State) ->
error_logger:info_msg("Terminating, reason: ~p; Pid none~n", [Reason]),
logger:info("Terminating, reason: ~p; Pid none~n", [Reason], #{domain => [ldclient]}),
ok.

%% @doc
Expand Down
Loading
Loading