This repository has been archived by the owner on Jan 19, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
In Log module now quoting values that contain spaces or = sign
- Loading branch information
Showing
5 changed files
with
53 additions
and
40 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,22 +12,32 @@ defmodule Openmaize.LogTest do | |
test "logs to console in standard logfmt" do | ||
assert capture_log(fn -> | ||
conn = conn(:get, "/confirm") |> assign(:current_user, @user) | ||
current_user_id = conn |> Log.current_user_id | ||
log_entry = %Log{ | ||
user: "[email protected]", | ||
message: "account confirmed", | ||
meta: [{"current_user_id", current_user_id}]} | ||
conn |> Log.logfmt(log_entry) |> Logger.warn | ||
end) =~ "path=/confirm [email protected] message=account confirmed current_user_id=1" | ||
Log.logfmt(conn, %Log{ | ||
user: "[email protected]", | ||
message: "account confirmed", | ||
meta: [{"current_user_id", Log.current_user_id(conn)}]}) | ||
|> Logger.warn | ||
end) =~ ~s(path=/confirm [email protected] message="account confirmed" current_user_id=1) | ||
end | ||
|
||
test "logs to console in standard logfmt for nil current_user" do | ||
assert capture_log(fn -> | ||
conn = conn(:get, "/login") |> assign(:current_user, nil) | ||
log_entry = %Log{ | ||
user: "[email protected]", | ||
message: "failed login"} | ||
conn |> Log.logfmt(log_entry) |> Logger.warn | ||
end) =~ "path=/login [email protected] message=failed login" | ||
Log.logfmt(conn, %Log{ | ||
user: "[email protected]", | ||
message: "failed login"}) | ||
|> Logger.warn | ||
end) =~ ~s(path=/login [email protected] message="failed login") | ||
end | ||
|
||
test "quotes values containing '='" do | ||
assert capture_log(fn -> | ||
conn = conn(:get, "/confirm") | ||
Log.logfmt(conn, %Log{ | ||
message: "invalid query string", | ||
meta: [{"query", "email=wrong%40mail.com"}]}) | ||
|> Logger.warn | ||
end) =~ ~s(path=/confirm user=nil message="invalid query string" query="email=wrong%40mail.com") | ||
end | ||
|
||
end |