iron / logger

Morgan-inspired request logger middleware for Iron
MIT License
25 stars 37 forks source link

Format strings support colors and terminal attributes. #11

Closed ghost closed 10 years ago

ghost commented 10 years ago

Syntax is @[color/attr]...@@. Also, from_format_string now takes a vec of colors and a vec of attributes--these are applied to places in the format string marked by @[C] for colors and @[A] for attributes, like the way format!/println!/printf interpret their arguments. These colors/attributes can be constants, or functions of request and response.

For example, the default format is now given by the format string

"@[bold]{method}@@ {uri} @[bold]->@@ @[C]{status}@@ ({response_time})"

with the vecs

Colors: vec![FunctionColor(status_color)], Attrs: vec![]

where status_color is a function that returns the appropriate option color from req and res.