SaltLog behaviour (salt_log v0.1.0)
Module dedicated to providing effective logging into our Salt Microservices.
Provides an integration into Timber.io for a better, managed experience of logs.
Link to this section Summary
Types
All context data stored
Data to store the context
Name of the context the Logs can be searched at.
Functions
Adds context the action being completed
Adds additional context to actions
Adds an error to the logs
Adds info to the logs to further inform events that are occurring
Adds the user's ID to the context to identify their actions
Callbacks
Adds additional context data to the Logging Library we use
Gets the context from the supported modules of the package. Currently this is Timber.
Link to this section Types
all_contexts_data()
Specs
all_contexts_data() :: map()
All context data stored
context_data()
Specs
context_data() :: map()
Data to store the context
context_name()
Specs
context_name() :: String.t()
Name of the context the Logs can be searched at.
Link to this section Functions
action_context(name, target_type, target_id, extra \\ %{})
Adds context the action being completed
Parameters
- name: Name of the action
- target_type: An atom describing the context in which is taking action
- target_id: An id for the action to be linked to
- extra: An optional map with extra action context info
Examples
iex> SaltLog.action_context(:claim_lead_merchant, :lead_merchant, merchant_id) :ok
action_context_add(extra)
Adds additional context to actions
Parameters
- extra: Extra values in Map
Examples
iex> extra = %{test: "test"} iex> SaltLog.action_context_add(extra) :ok
error(message)
Adds an error to the logs
Parameters
- message: Error text to be added to the log
Examples
iex> SaltLog.error("Test error message") :ok
info(message)
Adds info to the logs to further inform events that are occurring
Parameters
- message: Text to be added to the log
Examples
iex> SaltLog.info("Test message") :ok
user_context(user_id)
Adds the user's ID to the context to identify their actions
Parameters
- user_id: User's UUID in platform
Examples
iex> user_id = "c5300395-11c0-45c8-8a05-b02058d79a04" iex> SaltLog.user_context(user_id) :ok
Link to this section Callbacks
add_context(context_name, context_data)
Specs
add_context(context_name(), context_data()) :: :ok | :error
Adds additional context data to the Logging Library we use
get_context()
Specs
get_context() :: all_contexts_data()
Gets the context from the supported modules of the package. Currently this is Timber.