forked from erlang-lager/lager
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Use an opaque type with a module for accessors rather than a record
I didn't want the lager_log_message record being used across application boundaries, this will insulate other applications from any changes to the message type's internal structure.
- Loading branch information
Showing
8 changed files
with
122 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
-module(lager_msg). | ||
|
||
-export([new/5]). | ||
-export([message/1]). | ||
-export([timestamp/1]). | ||
-export([severity/1]). | ||
-export([severity_as_int/1]). | ||
-export([metadata/1]). | ||
-export([destinations/1]). | ||
|
||
-record(lager_msg,{ | ||
destinations :: list(), | ||
metadata :: [tuple()], | ||
severity :: lager:log_level(), | ||
timestamp :: {string(), string()}, | ||
message :: list() | ||
}). | ||
|
||
-opaque lager_msg() :: #lager_msg{}. | ||
-export_type([lager_msg/0]). | ||
|
||
-spec new(list(), {string(), string()}, atom(), [tuple()], list()) -> lager_msg(). | ||
new(Msg, Timestamp, Severity, Metadata, Destinations) -> | ||
#lager_msg{message=Msg, timestamp=Timestamp, severity=Severity, | ||
metadata=Metadata, destinations=Destinations}. | ||
|
||
-spec message(lager_msg()) -> list(). | ||
message(Msg) -> | ||
Msg#lager_msg.message. | ||
|
||
-spec timestamp(lager_msg()) -> {string(), string()}. | ||
timestamp(Msg) -> | ||
Msg#lager_msg.timestamp. | ||
|
||
-spec severity(lager_msg()) -> lager:log_level(). | ||
severity(Msg) -> | ||
Msg#lager_msg.severity. | ||
|
||
-spec severity_as_int(lager_msg()) -> lager:log_level_number(). | ||
severity_as_int(Msg) -> | ||
lager_util:level_to_num(Msg#lager_msg.severity). | ||
|
||
-spec metadata(lager_msg()) -> [tuple()]. | ||
metadata(Msg) -> | ||
Msg#lager_msg.metadata. | ||
|
||
-spec destinations(lager_msg()) -> list(). | ||
destinations(Msg) -> | ||
Msg#lager_msg.destinations. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters