Fossil SCM

Add "Truncate" and "Download" buttons to the /errorlog display. Provide a link to the error log on the /setup page.

drh 2018-07-12 14:09 trunk
Commit 8e3bad04eef13d83fc44cc980a345b153cdc1c22a8a6e804f2f99a4d70b5af7e
--- src/security_audit.c
+++ src/security_audit.c
@@ -396,11 +396,11 @@
396396
}
397397
398398
/*
399399
** The maximum number of bytes of log to show
400400
*/
401
-#define MXSHOWLOG 20000
401
+#define MXSHOWLOG 50000
402402
403403
/*
404404
** WEBPAGE: errorlog
405405
**
406406
** Show the content of the error log. Only the administrator can view
@@ -415,11 +415,10 @@
415415
login_needed(0);
416416
return;
417417
}
418418
style_header("Server Error Log");
419419
if( g.zErrlog==0 || fossil_strcmp(g.zErrlog,"-")==0 ){
420
- @ <p>There is no server error log!
421420
@ <p>To create a server error log:
422421
@ <ol>
423422
@ <li><p>
424423
@ If the server is running as CGI, then create a line in the CGI file
425424
@ like this:
@@ -432,13 +431,29 @@
432431
@ a command-line option "--errorlog <i>FILENAME</i>" to that
433432
@ command.
434433
@ </ol>
435434
style_footer();
436435
return;
436
+ }
437
+ if( P("truncate") && cgi_csrf_safe(1) ){
438
+ fclose(fopen(g.zErrlog,"w"));
439
+ }
440
+ if( P("download") ){
441
+ Blob log;
442
+ blob_read_from_file(&log, g.zErrlog, ExtFILE);
443
+ cgi_set_content_type("text/plain");
444
+ cgi_set_content(&log);
445
+ return;
437446
}
438447
szFile = file_size(g.zErrlog, ExtFILE);
448
+ @ <form action="%R/errorlog" method="POST">
439449
@ <p>The server error log at "%h(g.zErrlog)" is %,lld(szFile) bytes in size.
450
+ if( szFile>1000 ){
451
+ @ <input type="submit" name="download" value="Download">
452
+ @ <input type="submit" name="truncate" value="Truncate">
453
+ }
454
+ @ </form>
440455
in = fossil_fopen(g.zErrlog, "rb");
441456
if( in==0 ){
442457
@ <p class='generalError'>Unable top open that file for reading!</p>
443458
style_footer();
444459
return;
445460
--- src/security_audit.c
+++ src/security_audit.c
@@ -396,11 +396,11 @@
396 }
397
398 /*
399 ** The maximum number of bytes of log to show
400 */
401 #define MXSHOWLOG 20000
402
403 /*
404 ** WEBPAGE: errorlog
405 **
406 ** Show the content of the error log. Only the administrator can view
@@ -415,11 +415,10 @@
415 login_needed(0);
416 return;
417 }
418 style_header("Server Error Log");
419 if( g.zErrlog==0 || fossil_strcmp(g.zErrlog,"-")==0 ){
420 @ <p>There is no server error log!
421 @ <p>To create a server error log:
422 @ <ol>
423 @ <li><p>
424 @ If the server is running as CGI, then create a line in the CGI file
425 @ like this:
@@ -432,13 +431,29 @@
432 @ a command-line option "--errorlog <i>FILENAME</i>" to that
433 @ command.
434 @ </ol>
435 style_footer();
436 return;
 
 
 
 
 
 
 
 
 
 
437 }
438 szFile = file_size(g.zErrlog, ExtFILE);
 
439 @ <p>The server error log at "%h(g.zErrlog)" is %,lld(szFile) bytes in size.
 
 
 
 
 
440 in = fossil_fopen(g.zErrlog, "rb");
441 if( in==0 ){
442 @ <p class='generalError'>Unable top open that file for reading!</p>
443 style_footer();
444 return;
445
--- src/security_audit.c
+++ src/security_audit.c
@@ -396,11 +396,11 @@
396 }
397
398 /*
399 ** The maximum number of bytes of log to show
400 */
401 #define MXSHOWLOG 50000
402
403 /*
404 ** WEBPAGE: errorlog
405 **
406 ** Show the content of the error log. Only the administrator can view
@@ -415,11 +415,10 @@
415 login_needed(0);
416 return;
417 }
418 style_header("Server Error Log");
419 if( g.zErrlog==0 || fossil_strcmp(g.zErrlog,"-")==0 ){
 
420 @ <p>To create a server error log:
421 @ <ol>
422 @ <li><p>
423 @ If the server is running as CGI, then create a line in the CGI file
424 @ like this:
@@ -432,13 +431,29 @@
431 @ a command-line option "--errorlog <i>FILENAME</i>" to that
432 @ command.
433 @ </ol>
434 style_footer();
435 return;
436 }
437 if( P("truncate") && cgi_csrf_safe(1) ){
438 fclose(fopen(g.zErrlog,"w"));
439 }
440 if( P("download") ){
441 Blob log;
442 blob_read_from_file(&log, g.zErrlog, ExtFILE);
443 cgi_set_content_type("text/plain");
444 cgi_set_content(&log);
445 return;
446 }
447 szFile = file_size(g.zErrlog, ExtFILE);
448 @ <form action="%R/errorlog" method="POST">
449 @ <p>The server error log at "%h(g.zErrlog)" is %,lld(szFile) bytes in size.
450 if( szFile>1000 ){
451 @ <input type="submit" name="download" value="Download">
452 @ <input type="submit" name="truncate" value="Truncate">
453 }
454 @ </form>
455 in = fossil_fopen(g.zErrlog, "rb");
456 if( in==0 ){
457 @ <p class='generalError'>Unable top open that file for reading!</p>
458 style_footer();
459 return;
460
--- src/setup.c
+++ src/setup.c
@@ -141,10 +141,12 @@
141141
"A record of received artifacts and their sources");
142142
setup_menu_entry("User Log", "access_log",
143143
"A record of login attempts");
144144
setup_menu_entry("Administrative Log", "admin_log",
145145
"View the admin_log entries");
146
+ setup_menu_entry("Error Log", "errorlog",
147
+ "View the Fossil server error log");
146148
setup_menu_entry("Unversioned Files", "uvlist?byage=1",
147149
"Show all unversioned files held");
148150
setup_menu_entry("Stats", "stat",
149151
"Repository Status Reports");
150152
setup_menu_entry("Sitemap", "sitemap",
151153
--- src/setup.c
+++ src/setup.c
@@ -141,10 +141,12 @@
141 "A record of received artifacts and their sources");
142 setup_menu_entry("User Log", "access_log",
143 "A record of login attempts");
144 setup_menu_entry("Administrative Log", "admin_log",
145 "View the admin_log entries");
 
 
146 setup_menu_entry("Unversioned Files", "uvlist?byage=1",
147 "Show all unversioned files held");
148 setup_menu_entry("Stats", "stat",
149 "Repository Status Reports");
150 setup_menu_entry("Sitemap", "sitemap",
151
--- src/setup.c
+++ src/setup.c
@@ -141,10 +141,12 @@
141 "A record of received artifacts and their sources");
142 setup_menu_entry("User Log", "access_log",
143 "A record of login attempts");
144 setup_menu_entry("Administrative Log", "admin_log",
145 "View the admin_log entries");
146 setup_menu_entry("Error Log", "errorlog",
147 "View the Fossil server error log");
148 setup_menu_entry("Unversioned Files", "uvlist?byage=1",
149 "Show all unversioned files held");
150 setup_menu_entry("Stats", "stat",
151 "Repository Status Reports");
152 setup_menu_entry("Sitemap", "sitemap",
153

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button