Added the ability to plug in a log function#7
Open
alexthornton1 wants to merge 1 commit intouwiger:masterfrom
Open
Added the ability to plug in a log function#7alexthornton1 wants to merge 1 commit intouwiger:masterfrom
alexthornton1 wants to merge 1 commit intouwiger:masterfrom
Conversation
Added the ability to plug in a log function in place of the existing
calls to io:fwrite and error_logger:format. The details are as follows:
(1) Added two new types to unsplit.hrl:
* log_type(), which is either the atom 'normal' or the atom 'error'.
Each log message has one type or the other.
* log_fun(), which is the kind of fun that writes log messages. It
takes two arguments: a log_type() and a string().
(2) Added a key 'log_fun' to the {unsplit, ...} application environment
variable in unsplit.app.src. Its value is a tuple {Module, FunctionName}.
(3) Added a function unsplit:default_log_fun, which is what it sounds like:
the default log_fun when none is explicitly specified. It writes normal
messages using io:fwrite and error messages using error_logger:format,
mirroring previous functionality.
(4) Added three overloads of a function unsplit:log_write, which writes
messages (with or without formatting) to whatever log function has
been configured in the {unsplit, ...} application environment variable.
(5) Added a function unsplit:get_logger, which builds a fun that calls the
appropriate log_fun.
(6) Replaced all explicit calls to io:fwrite(...) with calls to
unsplit:log_write(normal, ...) instead.
(7) Replaced all explicit calls to error_logger:format(...) with calls to
unsplit:log_write(error, ...) instead.
(8) Regenerated unsplit.md documentation file.
When the new 'log_fun' application environment variable has its default
value, unsplit behaves as it did before. However, logging functionality
can now be plugged in to replace the existing functionality.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Added the ability to plug in a log function in place of the existing
calls to io:fwrite and error_logger:format. The details are as follows:
(1) Added two new types to unsplit.hrl:
(2) Added a key 'log_fun' to the {unsplit, ...} application environment
variable in unsplit.app.src. Its value is a tuple {Module, FunctionName}.
(3) Added a function unsplit:default_log_fun, which is what it sounds like:
the default log_fun when none is explicitly specified. It writes normal
messages using io:fwrite and error messages using error_logger:format,
mirroring previous functionality.
(4) Added three overloads of a function unsplit:log_write, which writes
messages (with or without formatting) to whatever log function has
been configured in the {unsplit, ...} application environment variable.
(5) Added a function unsplit:get_logger, which builds a fun that calls the
appropriate log_fun.
(6) Replaced all explicit calls to io:fwrite(...) with calls to
unsplit:log_write(normal, ...) instead.
(7) Replaced all explicit calls to error_logger:format(...) with calls to
unsplit:log_write(error, ...) instead.
(8) Regenerated unsplit.md documentation file.
When the new 'log_fun' application environment variable has its default
value, unsplit behaves as it did before. However, logging functionality
can now be plugged in to replace the existing functionality.