@@ -40,9 +40,12 @@ defmodule Logger.Formatter do
4040 value.
4141 """
4242
43+ @ type time :: { { 1970 .. 10000 , 1 .. 12 , 1 .. 31 } , { 0 .. 23 , 0 .. 59 , 0 .. 59 , 0 .. 999 } }
44+ @ type pattern :: :date | :level | :levelpad | :message | :metadata | :node | :time
4345 @ valid_patterns [ :time , :date , :message , :level , :node , :metadata , :levelpad ]
4446 @ default_pattern "\n $time $metadata[$level] $levelpad$message\n "
4547
48+
4649 @ doc ~S"""
4750 Compiles a format string into an array that the `format/5` can handle.
4851
@@ -55,7 +58,7 @@ defmodule Logger.Formatter do
5558 iex> Logger.Formatter.compile("$time $metadata [$level] $message\n")
5659 [:time, " ", :metadata, " [", :level, "] ", :message, "\n"]
5760 """
58- @ spec compile ( binary | nil ) :: list ( )
61+ @ spec compile ( binary | nil ) :: [ pattern | binary ]
5962 @ spec compile ( { atom , atom } ) :: { atom , atom }
6063
6164 def compile ( nil ) , do: compile ( @ default_pattern )
@@ -80,6 +83,8 @@ defmodule Logger.Formatter do
8083 metadata listdict and returns a properly formatted string.
8184 """
8285
86+ @ spec format ( { atom , atom } | [ pattern | binary ] , Logger . level , Logger . message , time , Keyword . t ) ::
87+ IO . chardata
8388 def format ( { mod , fun } , level , msg , ts , md ) do
8489 apply ( mod , fun , [ level , msg , ts , md ] )
8590 end
0 commit comments