[ 
https://issues.apache.org/jira/browse/TS-2364?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13827306#comment-13827306
 ] 

ASF subversion and git services commented on TS-2364:
-----------------------------------------------------

Commit 6dc186740eea69c180fdda732608d8b0fedfcbf3 in branch refs/heads/master 
from [~yunkai]
[ https://git-wip-us.apache.org/repos/asf?p=trafficserver.git;h=6dc1867 ]

TS-2364: Introduce slice notation to field syntax in log format

Now, we have two kind of field syntax in log format:
(1) simple syntax: '%<field>', for example: %<cqu>
(2) container field, syntax: '%<{field}container>',
    for example: %<{Referer}cqh>.

This patch introduces slice notation to field syntax, so that we can easy to
limit the length of filed's output. With slice notation, the filed syntax will
looks like:
(1) '%<field[start:end]>'
(2) '%<{field}container[start:end]>'

In both forms, slice notation can be omitted, which means the whole field.

But with one limitation: slice notation makes sense only when the field is
string type and it shouldn't be ip/timestamp which are converted to
string from integer.

We can see the syntax of slice notation from Python, Golang, it's pretty
simple:
  [start:end] //items start through end-1
  [start:]    //items start through the rest of the array
  [:end]      //items from the beginning through end-1
  [:]         //the whole array(by default)

For example,
  '%<cqup>'       //the whole characters of <cqup>.
  '%<cqup>[:]'    //the whole characters of <cqup>.
  '%<cqup[0:30]>' //the first 30 characters of <cqup>.
  '%<cqup[-10:]>' //the last 10 characters of <cqup>.
  '%<cqup[:-5]>'  //everything except the last 5 characters of <cqup>.

Signed-off-by: Yunkai Zhang <[email protected]>


> Introduce slice notation to field syntax in log format
> ------------------------------------------------------
>
>                 Key: TS-2364
>                 URL: https://issues.apache.org/jira/browse/TS-2364
>             Project: Traffic Server
>          Issue Type: New Feature
>          Components: Logging
>            Reporter: Yunkai Zhang
>            Assignee: Yunkai Zhang
>             Fix For: 4.2.0
>
>         Attachments: 
> 0001-TS-2364-Introduce-slice-notation-to-field-syntax-in-.V2.patch, 
> 0001-TS-2364-Introduce-slice-notation-to-field-syntax-in-.patch
>
>
> Now, we have two kind of field syntax in log format:
> {code}
> (1) simple; syntax: '%<field>', for example: %<cqu>
> (2) container field, syntax '%<{field}container>', for example: 
> %<{Referer}cqh>.
> {code}
> I'm going to introduce slice notation, so that we can easy to limit the 
> length of filed's output. With slice notation, the filed syntax will looks 
> like:
> {code}
> (1) '%<field[start:end]>'
> (2) '%<{field}container[start:end]>'
> {code}
> In both forms, slice notation can be omitted, which means the whole field. 
> But with one limitation: slice notation makes sense only when the field is 
> string type and it shouldn't be ip/timestamp which are converted to string 
> from integer.
> We can see the syntax of slice notation from Python, Golang, it's pretty 
> simple:
> {code}
> [start:end] //items start through end-1
> [start:]    //items start through the rest of the array
> [:end]      //items from the beginning through end-1
> [:]         //the whole array(by default)
> {code}
> For example, 
> {code}
> '%<cqh>'       //the whole characters of <cqh>.
> '%<cqh>[:]'    //the whole characters of <cqh>.
> '%<cqh[0:30]>' //the first 30 characters of <cqh>.
> '%<cqh[-10:]>' //the last 10 characters of <cqh>.
> '%<cqh[:-5]>'  //everything except the last 5 characters of <cqh>.
> {code}



--
This message was sent by Atlassian JIRA
(v6.1#6144)

Reply via email to