File Coverage

blib/lib/Dancer2/Plugin/Tail.pm
Criterion Covered Total %
statement 26 112 23.2
branch 0 18 0.0
condition 0 8 0.0
subroutine 5 9 55.5
pod 0 3 0.0
total 31 150 20.6


line stmt bran cond sub pod time code
1             package Dancer2::Plugin::Tail;
2              
3 1     1   643234 use Dancer2::Core::Types qw(Bool HashRef Str);
  1         3  
  1         5  
4 1     1   1567 use Dancer2::Plugin;
  1         11420  
  1         6  
5              
6 1     1   2795 use Carp;
  1         2  
  1         45  
7 1     1   477 use Session::Token;
  1         7607  
  1         1181  
8              
9             =head1 NAME
10              
11             Dancer2::Plugin::Tail - Tail a file from Dancer2
12              
13              
14             =head1 VERSION
15              
16             Version 0.016
17              
18             =cut
19              
20             our $VERSION = '0.016';
21              
22              
23             =head1 SYNOPSIS
24              
25             use Dancer2;
26             use Dancer2::Plugin::Tail;
27              
28              
29             =head1 DESCRIPTION
30              
31             This plugin will allow you to tail a file from within Dancer2. It's designed to be unobtrusive. So, it is functional just by calling it from your scripts. Edit entries in the Dancer configuration to setup routes and activate files that may be tailed. Additionally, you may define or restrict definition of tailed files.
32              
33              
34             =head1 CONFIGURATION
35              
36             You may specify the route to files. The plugin will only read files so Dancer2 must have read access to them. The following configuration will generate two routes: '/tail/display' and '/tail/read'.
37              
38             A sample HTML page with Bootstrap and jQuery is included in the samples directory. Use it as an example to build your own page.
39              
40             plugins:
41             Tail:
42             update_interval: 3000
43             stop_on_empty_cnt: 5
44             tmpdir: '/tmp'
45             display:
46             method: 'get'
47             url: '/tail/display'
48             template: 'tail.tt'
49             layout: 'nomenu.tt'
50             data:
51             method: 'get'
52             url: '/tail/read'
53             files:
54             id1:
55             heading: 'Server Access Log'
56             file: '/var/logs/access_log'
57             id2:
58             heading: 'Server Error Log'
59             file: '/var/logs/error_log'
60              
61             =over
62              
63             =item I
64              
65             Specify an update interval. Default is 3 seconds (3000). This value is passed to your web page or window. See example that's included.
66              
67              
68             =item I
69              
70             Specify the number of empty responses before stopping. Default is 10. This value is passed to your web page or window. See example that's included.
71              
72              
73             =item I
74              
75             location of user generted files to tail. Default is '/tmp'.
76              
77              
78             =item I
79              
80             Defines display settings.
81              
82             =over 4
83              
84             =item I
85              
86             Default 'get'.
87              
88              
89             =item I
90              
91             Route in Dancer2 to display template for tailing.
92             Default = '/tail/display'
93              
94              
95             =item I