Skip to content

Commit

Permalink
feat(endpoint, cli): support to convert logs to xlsx
Browse files Browse the repository at this point in the history
  • Loading branch information
macrat committed Dec 8, 2022
1 parent bec614a commit 9b78736
Show file tree
Hide file tree
Showing 17 changed files with 368 additions and 5 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,7 @@ Ayd has these pages/endpoints.
| [/incidents.json](http://localhost:9000/status.json) | Incident history in JSON format. |
| [/log.html](http://localhost:9000/log.html) | Raw log data in HTML page. |
| [/log.csv](http://localhost:9000/log.csv) | Raw log file in CSV format. |
| [/log.xlsx](http://localhost:9000/log.xlsx) | Raw log file in Microsoft Excel (OpenXML Spreadsheet) format. |
| [/log.ltsv](http://localhost:9000/log.ltsv) | Raw log file in LTSV (Labeled Tab-Separated Values) format. |
| [/log.json](http://localhost:9000/log.json) | Raw log file in JSON format. |
| [/targets.txt](http://localhost:9000/targets.txt) | The list of target URLs, separated by \\n. |
Expand Down
23 changes: 23 additions & 0 deletions cmd/ayd/conv.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ import (
"fmt"
"io"
"os"
"time"

"github.com/macrat/ayd/internal/logconv"
api "github.com/macrat/ayd/lib-ayd"
"github.com/mattn/go-isatty"
"github.com/spf13/pflag"
)

Expand All @@ -33,6 +35,7 @@ Options:
-c, --csv Convert to CSV. (default format)
-j, --json Convert to JSON.
-l, --ltsv Convert to LTSV.
-x, --xlsx Convert to XLSX.
-h, --help Show this help message and exit.
`
Expand All @@ -45,6 +48,7 @@ func (c ConvCommand) Run(args []string) int {
toCsv := flags.BoolP("csv", "c", false, "Convert to CSV")
toJson := flags.BoolP("json", "j", false, "Convert to JSON")
toLtsv := flags.BoolP("ltsv", "l", false, "Convert to LTSV")
toXlsx := flags.BoolP("xlsx", "x", false, "Convert to XLSX")

help := flags.BoolP("help", "h", false, "Show this message and exit")

Expand All @@ -69,6 +73,9 @@ func (c ConvCommand) Run(args []string) int {
if *toLtsv {
count++
}
if *toXlsx {
count++
}
if count > 1 {
fmt.Fprintln(c.ErrStream, "error: flags for output format can not use multiple in the same time.")
return 2
Expand Down Expand Up @@ -102,6 +109,9 @@ func (c ConvCommand) Run(args []string) int {
}
defer f.Close()
output = f
} else if *toXlsx && isatty.IsTerminal(os.Stdout.Fd()) || isatty.IsCygwinTerminal(os.Stdout.Fd()) {
fmt.Fprintln(c.ErrStream, "error: can not write xlsx format to stdout. please redirect or use -o option.")
return 2
}

var err error
Expand All @@ -110,6 +120,8 @@ func (c ConvCommand) Run(args []string) int {
err = c.toJson(scanners, output)
case *toLtsv:
err = c.toLTSV(scanners, output)
case *toXlsx:
err = c.toXlsx(scanners, output)
default:
err = c.toCSV(scanners, output)
}
Expand Down Expand Up @@ -167,3 +179,14 @@ func (c ConvCommand) toLTSV(scanners []api.LogScanner, output io.Writer) error {

return nil
}

func (c ConvCommand) toXlsx(scanners []api.LogScanner, output io.Writer) error {
createdAt := time.Now()
for _, s := range scanners {
if err := logconv.ToXlsx(output, s, createdAt); err != nil {
return err
}
}

return nil
}
8 changes: 4 additions & 4 deletions cmd/ayd/conv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,28 +82,28 @@ func TestConvCommand_Run(t *testing.T) {
},
{
[]string{"-j", "-c"},
testutil.DummyLog,
``,
"",
"error: flags for output format can not use multiple in the same time.\n",
2,
},
{
[]string{"-c", "./testdata/no-such-file"},
testutil.DummyLog,
``,
"",
"error: failed to open input log file: .*\n",
1,
},
{
[]string{"-h"},
testutil.DummyLog,
``,
main.ConvHelp,
"",
0,
},
{
[]string{"--no-such-option"},
testutil.DummyLog,
``,
"",
"unknown flag: --no-such-option\n\nPlease see `ayd conv -h` for more information.\n",
2,
Expand Down
8 changes: 8 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ require (
github.com/google/uuid v1.3.0
github.com/jlaffaye/ftp v0.1.0
github.com/macrat/go-parallel-pinger v1.1.3
github.com/mattn/go-isatty v0.0.16
github.com/robfig/cron/v3 v3.0.1
github.com/spf13/pflag v1.0.5
github.com/xuri/excelize/v2 v2.6.1
goftp.io/server v0.4.1
golang.org/x/sys v0.2.0
golang.org/x/text v0.4.0
Expand All @@ -19,5 +21,11 @@ require (
require (
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
github.com/richardlehane/mscfb v1.0.4 // indirect
github.com/richardlehane/msoleps v1.0.3 // indirect
github.com/xuri/efp v0.0.0-20220603152613-6918739fd470 // indirect
github.com/xuri/nfp v0.0.0-20220409054826-5e722a1d9e22 // indirect
golang.org/x/crypto v0.0.0-20220817201139-bc19a97f63c8 // indirect
golang.org/x/net v0.2.0 // indirect
)
31 changes: 31 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,20 @@ github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfV
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/macrat/go-parallel-pinger v1.1.3 h1:WpD2jHXoOn/A2Uy0CAvd85lpNHzX0jnO0hYSDcyEHA0=
github.com/macrat/go-parallel-pinger v1.1.3/go.mod h1:6Vkhm1prLe3/7Go6AUE6M9n0UjD94IwDK0iz/SystUc=
github.com/mattn/go-isatty v0.0.16 h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peKQ=
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/minio/minio-go/v6 v6.0.46/go.mod h1:qD0lajrGW49lKZLtXKtCB4X/qkMf0a5tBvN2PaZg7Gg=
github.com/minio/sha256-simd v0.1.1/go.mod h1:B5e1o+1/KgNmWrSQK08Y6Z1Vb5pwIktudl0J58iy0KM=
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw=
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/richardlehane/mscfb v1.0.4 h1:WULscsljNPConisD5hR0+OyZjwK46Pfyr6mPu5ZawpM=
github.com/richardlehane/mscfb v1.0.4/go.mod h1:YzVpcZg9czvAuhk9T+a3avCpcFPMUWm7gK3DypaEsUk=
github.com/richardlehane/msoleps v1.0.1/go.mod h1:BWev5JBpU9Ko2WAgmZEuiz4/u3ZYTKbjLycmwiWUfWg=
github.com/richardlehane/msoleps v1.0.3 h1:aznSZzrwYRl3rLKRT3gUk9am7T/mLNSnJINvN0AQoVM=
github.com/richardlehane/msoleps v1.0.3/go.mod h1:BWev5JBpU9Ko2WAgmZEuiz4/u3ZYTKbjLycmwiWUfWg=
github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
Expand All @@ -38,37 +47,59 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
github.com/xuri/efp v0.0.0-20220603152613-6918739fd470 h1:6932x8ltq1w4utjmfMPVj09jdMlkY0aiA6+Skbtl3/c=
github.com/xuri/efp v0.0.0-20220603152613-6918739fd470/go.mod h1:ybY/Jr0T0GTCnYjKqmdwxyxn2BQf2RcQIIvex5QldPI=
github.com/xuri/excelize/v2 v2.6.1 h1:ICBdtw803rmhLN3zfvyEGH3cwSmZv+kde7LhTDT659k=
github.com/xuri/excelize/v2 v2.6.1/go.mod h1:tL+0m6DNwSXj/sILHbQTYsLi9IF4TW59H2EF3Yrx1AU=
github.com/xuri/nfp v0.0.0-20220409054826-5e722a1d9e22 h1:OAmKAfT06//esDdpi/DZ8Qsdt4+M5+ltca05dA5bG2M=
github.com/xuri/nfp v0.0.0-20220409054826-5e722a1d9e22/go.mod h1:WwHg+CVyzlv/TX9xqBFXEZAuxOPxn2k1GNHwG41IIUQ=
goftp.io/server v0.4.1 h1:x7KG4HIxSMdK/rpYhExMinRN/aO/T9icvaG/B5e/XfY=
goftp.io/server v0.4.1/go.mod h1:hFZeR656ErRt3ojMKt7H10vQ5nuWV1e0YeUTeorlR6k=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190513172903-22d7a77e9e5f/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20220817201139-bc19a97f63c8 h1:GIAS/yBem/gq2MUqgNIzUHW7cJMmx3TGZOrnyYaNQ6c=
golang.org/x/crypto v0.0.0-20220817201139-bc19a97f63c8/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/image v0.0.0-20220413100746-70e8d0d3baa9 h1:LRtI4W37N+KFebI/qV0OFiLUv4GLOWeEW5hn/KEJvxE=
golang.org/x/image v0.0.0-20220413100746-70e8d0d3baa9/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20220403103023-749bd193bc2b/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
golang.org/x/net v0.0.0-20220812174116-3211cb980234/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
golang.org/x/net v0.2.0 h1:sZfSu1wtKLGlWI4ZZayP0ck9Y73K1ynO6gqzTdBVdPU=
golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220405210540-1e041c57c461/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.2.0 h1:ljd4t30dBnAvMZaQCevtY0xLLD0A+bRZXbgLMLU1F/A=
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.4.0 h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg=
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/ini.v1 v1.42.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
1 change: 1 addition & 0 deletions internal/endpoint/benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ func Benchmark_endpoints(b *testing.B) {
{"/incidents.csv", endpoint.IncidentsCSVEndpoint},
{"/log.html", endpoint.LogHTMLEndpoint},
{"/log.csv", endpoint.LogCSVEndpoint},
{"/log.xlsx", endpoint.LogXlsxEndpoint},
{"/log.ltsv", endpoint.LogLTSVEndpoint},
{"/log.json", endpoint.LogJsonEndpoint},
{"/metrics", endpoint.MetricsEndpoint},
Expand Down
3 changes: 2 additions & 1 deletion internal/endpoint/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,11 @@ func New(s Store) http.Handler {
m.Handle("/incidents.csv", LinkHeader{IncidentsCSVEndpoint(s), incidentsLink})
m.Handle("/incidents.json", LinkHeader{IncidentsJSONEndpoint(s), incidentsLink})

logLink := `<log.html>;rel="alternate";type="text/html", <log.csv>;rel="alternate";type="text/csv", <log.ltsv>;rel="alternate";type="text/plain", <log.json>;rel="alternate";type="application/json"`
logLink := `<log.html>;rel="alternate";type="text/html", <log.csv>;rel="alternate";type="text/csv", <log.xlsx>;rel="alternate";type="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", <log.ltsv>;rel="alternate";type="text/plain", <log.json>;rel="alternate";type="application/json"`
m.Handle("/log", http.RedirectHandler("/log.html", http.StatusMovedPermanently))
m.Handle("/log.html", LinkHeader{LogHTMLEndpoint(s), logLink})
m.Handle("/log.csv", LinkHeader{LogCSVEndpoint(s), logLink})
m.Handle("/log.xlsx", LinkHeader{LogXlsxEndpoint(s), logLink})
m.Handle("/log.ltsv", LinkHeader{LogLTSVEndpoint(s), logLink})
m.Handle("/log.json", LinkHeader{LogJsonEndpoint(s), logLink})

Expand Down
18 changes: 18 additions & 0 deletions internal/endpoint/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,24 @@ func LogLTSVEndpoint(s Store) http.HandlerFunc {
}
}

func LogXlsxEndpoint(s Store) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")

scanner, code, err := newLogScanner(s, "log.xlsx", r)
if err != nil {
w.WriteHeader(code)
w.Write([]byte(err.Error() + "\n"))
return
}
defer scanner.Close()

scanner = setFilter(scanner, r)
err = logconv.ToXlsx(w, scanner, time.Now())
handleError(s, "log.xlsx", err)
}
}

//go:embed templates/log.html
var logHTMLTemplate string

Expand Down
17 changes: 17 additions & 0 deletions internal/endpoint/log_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,23 @@ func TestLogCSVEndpoint(t *testing.T) {
}
}

func TestLogXlsxEndpoint(t *testing.T) {
srv := testutil.StartTestServer(t)
t.Cleanup(func() {
srv.Close()
})

resp, err := srv.Client().Get(srv.URL + "/log.xlsx")
if err != nil {
t.Fatalf("failed to get /log.xlsx: %s", err)
}
defer resp.Body.Close()

if resp.StatusCode != 200 {
t.Errorf("unexpected status: %s", resp.Status)
}
}

func TestLogLTSVEndpoint(t *testing.T) {
tests := []struct {
Name string
Expand Down
1 change: 1 addition & 0 deletions internal/endpoint/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ <h1>
<a href="/log.html" type="text/html">Log</a>
<ul class="menu-types">
<li><a href="/log.csv" type="text/csv">CSV</a></li>
<li><a href="/log.xlsx" type="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet">XLSX</a></li>
<li><a href="/log.ltsv" type="text/plain">LTSV</a></li>
<li><a href="/log.json" type="application/json">json</a></li>
</ul>
Expand Down
1 change: 1 addition & 0 deletions internal/endpoint/templates/log.html
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@
{{ .Count }} of {{ .Total }} records have shown<br />
download all log as
<a href="{{ printf "/log.csv?%s" .RawQuery }}" type="text/csv" download="ayd-log.csv">CSV</a>
<a href="{{ printf "/log.xlsx?%s" .RawQuery }}" type="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" download="ayd-log.xlsx">XLSX</a>
<a href="{{ printf "/log.ltsv?%s" .RawQuery }}" type="text/plain" download="ayd-log.ltsv">LTSV</a>
<a href="{{ printf "/log.json?%s" .RawQuery }}" type="application/json" download="ayd-log.json">JSON</a>
</div>
Expand Down
1 change: 1 addition & 0 deletions internal/endpoint/testdata/incidents.html
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@
<a href="/log.html" type="text/html">Log</a>
<ul class="menu-types">
<li><a href="/log.csv" type="text/csv">CSV</a></li>
<li><a href="/log.xlsx" type="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet">XLSX</a></li>
<li><a href="/log.ltsv" type="text/plain">LTSV</a></li>
<li><a href="/log.json" type="application/json">json</a></li>
</ul>
Expand Down
2 changes: 2 additions & 0 deletions internal/endpoint/testdata/log.html
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@
<a href="/log.html" type="text/html">Log</a>
<ul class="menu-types">
<li><a href="/log.csv" type="text/csv">CSV</a></li>
<li><a href="/log.xlsx" type="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet">XLSX</a></li>
<li><a href="/log.ltsv" type="text/plain">LTSV</a></li>
<li><a href="/log.json" type="application/json">json</a></li>
</ul>
Expand Down Expand Up @@ -336,6 +337,7 @@
7 of 7 records have shown<br />
download all log as
<a href="/log.csv?query=&amp;since=2021-01-01T00%3A00%3A00Z&amp;until=2021-01-03T00%3A00%3A00Z" type="text/csv" download="ayd-log.csv">CSV</a>
<a href="/log.xlsx?query=&amp;since=2021-01-01T00%3A00%3A00Z&amp;until=2021-01-03T00%3A00%3A00Z" type="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" download="ayd-log.xlsx">XLSX</a>
<a href="/log.ltsv?query=&amp;since=2021-01-01T00%3A00%3A00Z&amp;until=2021-01-03T00%3A00%3A00Z" type="text/plain" download="ayd-log.ltsv">LTSV</a>
<a href="/log.json?query=&amp;since=2021-01-01T00%3A00%3A00Z&amp;until=2021-01-03T00%3A00%3A00Z" type="application/json" download="ayd-log.json">JSON</a>
</div>
Expand Down
1 change: 1 addition & 0 deletions internal/endpoint/testdata/status.html
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@
<a href="/log.html" type="text/html">Log</a>
<ul class="menu-types">
<li><a href="/log.csv" type="text/csv">CSV</a></li>
<li><a href="/log.xlsx" type="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet">XLSX</a></li>
<li><a href="/log.ltsv" type="text/plain">LTSV</a></li>
<li><a href="/log.json" type="application/json">json</a></li>
</ul>
Expand Down
Binary file added internal/logconv/testdata/log.xlsx
Binary file not shown.
Loading

0 comments on commit 9b78736

Please sign in to comment.