Skip to content

Commit

Permalink
Add function for manual log tests
Browse files Browse the repository at this point in the history
  • Loading branch information
maehjam committed May 3, 2024
1 parent b24dff1 commit 38d9f99
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/grisp_connect.erl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

-module(grisp_connect).

-include_lib("kernel/include/logger.hrl").

%--- Exports -------------------------------------------------------------------

% API functions
Expand All @@ -14,6 +16,7 @@
-export([link_device/0]).
-export([link_device/1]).
-export([log/2]).
-export([test_log_encoding/0]).

%--- API Functions -------------------------------------------------------------

Expand Down Expand Up @@ -51,3 +54,13 @@ link_device(Token) ->

% @doc Log from inside grisp_connect for testing.
log(Level, Args) -> apply(logger, Level, Args).

% @doc For manually testing the log encoding.
% Alternative to shell commands. The shell double encodes unicode strings.
test_log_encoding() ->
String = "@#$%^&*()_ +{}|:\"<>?-[];'./,\\`~!\néäüßóçøáîùêñÄÖÜÉÁÍÓÚàèìòùÂÊÎÔÛ",
Binary = <<"@#$%^&*()_ +{}|:\"<>?-[];'./,\\`~!\néäüßóçøáîùêñÄÖÜÉÁÍÓÚàèìòùÂÊÎÔÛ"/utf8>>,
?LOG_NOTICE("List:\n" ++ String),
?LOG_NOTICE(<<"Binary: \n", Binary/binary>>),
?LOG_NOTICE("List:~n~tp~nBinary:~n~tp~n", [String, Binary]),
?LOG_NOTICE(#{list => String, binary => Binary}).

0 comments on commit 38d9f99

Please sign in to comment.