3 # Display global logging options
5 require './bind8-lib.pl';
6 $access{'defaults'} || &error($text{'logging_ecannot'});
7 &ui_print_header(undef, $text{'logging_title'}, "",
8 undef, undef, undef, undef, &restart_links());
10 $conf = &get_config();
11 $logging = &find("logging", $conf);
12 $mems = $logging ? $logging->{'members'} : [ ];
14 # Start of tabs for channels and categories
15 @tabs = ( [ "chans", $text{'logging_chans'}, "conf_logging.cgi?mode=chans" ],
16 [ "cats", $text{'logging_cats'}, "conf_logging.cgi?mode=cats" ] );
17 print &ui_tabs_start(\@tabs, "mode", $in{'mode'} || "chans", 1);
19 print &ui_tabs_start_tab("mode", "chans");
20 print $text{'logging_chansdesc'},"<p>\n";
22 # Add default channels to table
24 @defchans = ( { 'name' => 'default_syslog',
26 'severity' => 'info' },
27 { 'name' => 'default_debug',
28 'file' => 'named.run',
29 'severity' => 'dynamic' },
30 { 'name' => 'default_stderr',
32 'severity' => 'info' },
35 foreach $c (@defchans) {
38 $c->{'syslog'} ? $c->{'syslog'} :
39 $c->{'file'} ? $text{'logging_file'}.
40 " <tt>".$c->{'file'}."</tt>" :
41 $c->{'fd'} ? $text{'logging_fd'}." <tt>".$c->{'fd'}."</tt>" :
42 $text{'logging_null'},
43 $c->{'severity'} || "<i>$text{'logging_any'}</i>",
48 # Add user-defined channels
50 @chans = &find("channel", $mems);
51 @channames = ( (map { $_->{'value'} } @chans) ,
52 'default_syslog', 'default_debug', 'default_stderr', 'null' );
54 for($i=0; $i<@chans; $i++) {
55 $cmems = $chans[$i]->{'members'};
56 $file = &find("file", $cmems);
57 $filestr = $file ? join(" ", @{$file->{'values'}}) : "";
58 $syslog = &find_value("syslog", $cmems);
59 $null = &find("null", $cmems);
60 $stderr = &find("stderr", $cmems);
64 push(@cols, &ui_textbox("cname_$i", $chans[$i]->{'value'}, 10));
68 $to = $file ? 0 : $syslog ? 1 : $stderr ? 3 : $null ? 2 : 0;
69 push(@dests, [ 0, $text{'logging_file'},
70 &ui_filebox("file_$i", $file->{'value'}, 40) ]);
71 push(@dests, [ 1, $text{'logging_syslog'},
72 &ui_select("syslog_$i", $syslog,
73 \@syslog_levels, 1, 0, $syslog ? 1 : 0) ]);
74 push(@dests, [ 3, $text{'logging_stderr'} ]);
75 push(@dests, [ 2, $text{'logging_null'} ]);
76 push(@cols, &ui_radio_table("to_$i", $to, \@dests));
79 $sev = &find("severity", $cmems);
80 push(@cols, &ui_select("sev_$i", $sev->{'value'},
82 map { [ $_, $_ eq 'debug' ? $text{'logging_debug'} :
83 $_ eq 'dynamic' ? $text{'logging_dyn'} : $_ ] }
86 "onChange='form.debug_$i.disabled = form.sev_$i.value != \"debug\"'"
88 &ui_textbox("debug_$i", $sev->{'value'} eq 'debug' ?
89 $sev->{'values'}->[1] : "", 5,
90 $sev->{'value'} ne "debug"));
92 # Log category, severity and time
93 push(@cols, &yes_no_default("print-category-$i",
94 &find_value("print-category", $cmems)));
95 push(@cols, &yes_no_default("print-severity-$i",
96 &find_value("print-severity", $cmems)));
98 push(@cols, &yes_no_default("print-time-$i",
99 &find_value("print-time", $cmems)));
101 push(@table, \@cols);
104 # Output the channels table
105 print &ui_form_columns_table(
107 [ [ undef, $text{'save'} ] ],
110 [ [ 'mode', 'chans' ] ],
111 [ $text{'logging_cname'}, $text{'logging_to'}, $text{'logging_sev'},
112 $text{'logging_pcat2'}, $text{'logging_psev2'},
113 $text{'logging_ptime2'} ],
119 print &ui_tabs_end_tab("mode", "chans");
121 # Start of categories tab
122 print &ui_tabs_start_tab("mode", "cats");
123 print $text{'logging_catsdesc'},"<p>\n";
125 # Build table of categories
127 @cats = ( &find("category", $mems), { } );
128 for($i=0; $i<@cats; $i++) {
130 foreach $c (@{$cats[$i]->{'members'}}) {
131 $cchan{$c->{'name'}}++;
134 &ui_select("cat_$i", $cats[$i]->{'value'},
135 [ [ "", " " ], @cat_list ],
136 1, 0, $cats[$i]->{'value'} ? 1 : 0),
137 join(" ", map { &ui_checkbox("cchan_$i", $_, $_, $cchan{$_}) }
143 print &ui_form_columns_table(
145 [ [ undef, $text{'save'} ] ],
148 [ [ 'mode', 'cats' ] ],
149 [ $text{'logging_cat'}, $text{'logging_cchans'} ],
155 print &ui_tabs_end_tab("mode", "cats");
156 print &ui_tabs_end(1);
158 &ui_print_footer("", $text{'index_return'});
160 # yes_no_default(name, value)
164 return &ui_select($n, lc($v), [ [ '', $text{'default'} ],
165 [ 'yes', $text{'yes'} ],
166 [ 'no', $text{'no'} ] ]);