github.com/kyleu/dbaudit@v0.0.2-0.20240321155047-ff2f2c940496/views/vadmin/Logs.html.go (about)

     1  // Code generated by qtc from "Logs.html". DO NOT EDIT.
     2  // See https://github.com/valyala/quicktemplate for details.
     3  
     4  // <!-- Content managed by Project Forge, see [projectforge.md] for details. -->
     5  
     6  //line views/vadmin/Logs.html:2
     7  package vadmin
     8  
     9  //line views/vadmin/Logs.html:2
    10  import (
    11  	"go.uber.org/zap/zapcore"
    12  
    13  	"github.com/kyleu/dbaudit/app"
    14  	"github.com/kyleu/dbaudit/app/controller/cutil"
    15  	"github.com/kyleu/dbaudit/app/util"
    16  	"github.com/kyleu/dbaudit/views/layout"
    17  )
    18  
    19  //line views/vadmin/Logs.html:11
    20  import (
    21  	qtio422016 "io"
    22  
    23  	qt422016 "github.com/valyala/quicktemplate"
    24  )
    25  
    26  //line views/vadmin/Logs.html:11
    27  var (
    28  	_ = qtio422016.Copy
    29  	_ = qt422016.AcquireByteBuffer
    30  )
    31  
    32  //line views/vadmin/Logs.html:11
    33  type Logs struct {
    34  	layout.Basic
    35  	Logs []*zapcore.Entry
    36  }
    37  
    38  //line views/vadmin/Logs.html:16
    39  func (p *Logs) StreamBody(qw422016 *qt422016.Writer, as *app.State, ps *cutil.PageState) {
    40  //line views/vadmin/Logs.html:16
    41  	qw422016.N().S(`
    42    <div class="card">
    43      <h3>Recent Logs</h3>
    44      `)
    45  //line views/vadmin/Logs.html:19
    46  	streamlogTable(qw422016, p.Logs)
    47  //line views/vadmin/Logs.html:19
    48  	qw422016.N().S(`
    49    </div>
    50  `)
    51  //line views/vadmin/Logs.html:21
    52  }
    53  
    54  //line views/vadmin/Logs.html:21
    55  func (p *Logs) WriteBody(qq422016 qtio422016.Writer, as *app.State, ps *cutil.PageState) {
    56  //line views/vadmin/Logs.html:21
    57  	qw422016 := qt422016.AcquireWriter(qq422016)
    58  //line views/vadmin/Logs.html:21
    59  	p.StreamBody(qw422016, as, ps)
    60  //line views/vadmin/Logs.html:21
    61  	qt422016.ReleaseWriter(qw422016)
    62  //line views/vadmin/Logs.html:21
    63  }
    64  
    65  //line views/vadmin/Logs.html:21
    66  func (p *Logs) Body(as *app.State, ps *cutil.PageState) string {
    67  //line views/vadmin/Logs.html:21
    68  	qb422016 := qt422016.AcquireByteBuffer()
    69  //line views/vadmin/Logs.html:21
    70  	p.WriteBody(qb422016, as, ps)
    71  //line views/vadmin/Logs.html:21
    72  	qs422016 := string(qb422016.B)
    73  //line views/vadmin/Logs.html:21
    74  	qt422016.ReleaseByteBuffer(qb422016)
    75  //line views/vadmin/Logs.html:21
    76  	return qs422016
    77  //line views/vadmin/Logs.html:21
    78  }
    79  
    80  //line views/vadmin/Logs.html:23
    81  func streamlogTable(qw422016 *qt422016.Writer, logs []*zapcore.Entry) {
    82  //line views/vadmin/Logs.html:23
    83  	qw422016.N().S(`
    84    <div class="overflow full-width">
    85      <table class="mt">
    86        <thead>
    87          <tr>
    88            <th>Level</th>
    89            <th>Message</th>
    90            <th>Occurred</th>
    91          </tr>
    92        </thead>
    93        <tbody>
    94  `)
    95  //line views/vadmin/Logs.html:34
    96  	for _, l := range logs {
    97  //line views/vadmin/Logs.html:34
    98  		qw422016.N().S(`        <tr>
    99            <td>
   100  `)
   101  //line views/vadmin/Logs.html:37
   102  		lv := l.Level.String()
   103  
   104  //line views/vadmin/Logs.html:38
   105  		switch lv {
   106  //line views/vadmin/Logs.html:39
   107  		case "debug", "trace":
   108  //line views/vadmin/Logs.html:39
   109  			qw422016.N().S(`            <em>debug</em>
   110  `)
   111  //line views/vadmin/Logs.html:41
   112  		case "error", "fatal":
   113  //line views/vadmin/Logs.html:41
   114  			qw422016.N().S(`            <div class="error">error</div>
   115  `)
   116  //line views/vadmin/Logs.html:43
   117  		default:
   118  //line views/vadmin/Logs.html:43
   119  			qw422016.N().S(`            `)
   120  //line views/vadmin/Logs.html:44
   121  			qw422016.E().S(lv)
   122  //line views/vadmin/Logs.html:44
   123  			qw422016.N().S(`
   124  `)
   125  //line views/vadmin/Logs.html:45
   126  		}
   127  //line views/vadmin/Logs.html:45
   128  		qw422016.N().S(`          </td>
   129            <td>`)
   130  //line views/vadmin/Logs.html:47
   131  		qw422016.E().S(l.Message)
   132  //line views/vadmin/Logs.html:47
   133  		qw422016.N().S(`</td>
   134            <td>`)
   135  //line views/vadmin/Logs.html:48
   136  		qw422016.E().S(util.TimeRelative(&l.Time))
   137  //line views/vadmin/Logs.html:48
   138  		qw422016.N().S(`</td>
   139          </tr>
   140  `)
   141  //line views/vadmin/Logs.html:50
   142  	}
   143  //line views/vadmin/Logs.html:50
   144  	qw422016.N().S(`      </tbody>
   145      </table>
   146    </div>
   147  `)
   148  //line views/vadmin/Logs.html:54
   149  }
   150  
   151  //line views/vadmin/Logs.html:54
   152  func writelogTable(qq422016 qtio422016.Writer, logs []*zapcore.Entry) {
   153  //line views/vadmin/Logs.html:54
   154  	qw422016 := qt422016.AcquireWriter(qq422016)
   155  //line views/vadmin/Logs.html:54
   156  	streamlogTable(qw422016, logs)
   157  //line views/vadmin/Logs.html:54
   158  	qt422016.ReleaseWriter(qw422016)
   159  //line views/vadmin/Logs.html:54
   160  }
   161  
   162  //line views/vadmin/Logs.html:54
   163  func logTable(logs []*zapcore.Entry) string {
   164  //line views/vadmin/Logs.html:54
   165  	qb422016 := qt422016.AcquireByteBuffer()
   166  //line views/vadmin/Logs.html:54
   167  	writelogTable(qb422016, logs)
   168  //line views/vadmin/Logs.html:54
   169  	qs422016 := string(qb422016.B)
   170  //line views/vadmin/Logs.html:54
   171  	qt422016.ReleaseByteBuffer(qb422016)
   172  //line views/vadmin/Logs.html:54
   173  	return qs422016
   174  //line views/vadmin/Logs.html:54
   175  }