// Copyright 2016 Documize Inc. . All rights reserved. // // This software (Documize Community Edition) is licensed under // GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html // // You can operate outside the AGPL restrictions by purchasing // Documize Enterprise Edition and obtaining a commercial license // by contacting . // // https://documize.com package papertrail import "strings" // the HTML that is rendered by this section. const renderTemplate = ` {{if .HasData}}

The Papertrail log for query {{.Config.Query}} contains {{.Count}} entries.

{{range $item := .Events}} {{end}}
Date Severity Message
{{ $item.Dated }} {{ $item.Severity }} {{ $item.Message }}
{{else}}

There are no Papertrail log entries to see.

{{end}} ` // Papertrail helpers type papertrailRender struct { Config papertrailConfig Events []papertrailEvent Count int Authenticated bool HasData bool } type papertrailSearch struct { Events []papertrailEvent `json:"events"` } type papertrailEvent struct { ID string `json:"id"` Dated string `json:"display_received_at"` Message string `json:"message"` Severity string `json:"severity"` } type papertrailConfig struct { APIToken string `json:"APIToken"` // only contains the correct token just after it is typed in Query string `json:"query"` Max int `json:"max"` Group papertrailOption `json:"group"` System papertrailOption `json:"system"` } func (c *papertrailConfig) Clean() { c.APIToken = strings.TrimSpace(c.APIToken) c.Query = strings.TrimSpace(c.Query) } type papertrailOption struct { ID int `json:"id"` Name string `json:"name"` } type papertrailOptions struct { Groups []papertrailOption `json:"groups"` Systems []papertrailOption `json:"systems"` }