Created
December 31, 2018 01:42
-
-
Save RikiyaOta/948f97392b47eaedeb780630af3eb9aa to your computer and use it in GitHub Desktop.
implement Plugs for setting log file path dinamically
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
pipeline :browser do | |
plug :accepts, ["html"] | |
plug :fetch_session | |
plug :fetch_flash | |
plug :protect_from_forgery | |
plug :put_secure_browser_headers | |
plug :set_log1_file_daily | |
plug :set_log2_file_daily | |
end | |
defp set_log1_file_daily(conn, _opts) do | |
today = Timex.now("Japan") |> Timex.format!("{YYYY}{0M}{0D}") | |
Logger.configure_backend {LoggerFileBackend, :log1}, | |
path: Path.join([File.cwd!, "var", "log", "log1-#{today}.log"]) | |
conn #Plug should return conn. | |
end | |
defp set_log2_file_daily(conn, _opts) do | |
today = Timex.now("Japan") |> Timex.format!("{YYYY}{0M}{0D}") | |
Logger.configure_backend {LoggerFileBackend, :log2}, | |
path: Path.join([File.cwd!, "var", "log", "log2-#{today}.log"]) | |
conn #Plug should return conn. | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment