Fossil SCM
Add "Truncate" and "Download" buttons to the /errorlog display. Provide a link to the error log on the /setup page.
Commit
8e3bad04eef13d83fc44cc980a345b153cdc1c22a8a6e804f2f99a4d70b5af7e
Parent
9a6c6c2cdacf4d8…
2 files changed
+17
-2
+2
+17
-2
| --- src/security_audit.c | ||
| +++ src/security_audit.c | ||
| @@ -396,11 +396,11 @@ | ||
| 396 | 396 | } |
| 397 | 397 | |
| 398 | 398 | /* |
| 399 | 399 | ** The maximum number of bytes of log to show |
| 400 | 400 | */ |
| 401 | -#define MXSHOWLOG 20000 | |
| 401 | +#define MXSHOWLOG 50000 | |
| 402 | 402 | |
| 403 | 403 | /* |
| 404 | 404 | ** WEBPAGE: errorlog |
| 405 | 405 | ** |
| 406 | 406 | ** Show the content of the error log. Only the administrator can view |
| @@ -415,11 +415,10 @@ | ||
| 415 | 415 | login_needed(0); |
| 416 | 416 | return; |
| 417 | 417 | } |
| 418 | 418 | style_header("Server Error Log"); |
| 419 | 419 | if( g.zErrlog==0 || fossil_strcmp(g.zErrlog,"-")==0 ){ |
| 420 | - @ <p>There is no server error log! | |
| 421 | 420 | @ <p>To create a server error log: |
| 422 | 421 | @ <ol> |
| 423 | 422 | @ <li><p> |
| 424 | 423 | @ If the server is running as CGI, then create a line in the CGI file |
| 425 | 424 | @ like this: |
| @@ -432,13 +431,29 @@ | ||
| 432 | 431 | @ a command-line option "--errorlog <i>FILENAME</i>" to that |
| 433 | 432 | @ command. |
| 434 | 433 | @ </ol> |
| 435 | 434 | style_footer(); |
| 436 | 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; | |
| 437 | 446 | } |
| 438 | 447 | szFile = file_size(g.zErrlog, ExtFILE); |
| 448 | + @ <form action="%R/errorlog" method="POST"> | |
| 439 | 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> | |
| 440 | 455 | in = fossil_fopen(g.zErrlog, "rb"); |
| 441 | 456 | if( in==0 ){ |
| 442 | 457 | @ <p class='generalError'>Unable top open that file for reading!</p> |
| 443 | 458 | style_footer(); |
| 444 | 459 | return; |
| 445 | 460 |
| --- 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 |
+2
| --- src/setup.c | ||
| +++ src/setup.c | ||
| @@ -141,10 +141,12 @@ | ||
| 141 | 141 | "A record of received artifacts and their sources"); |
| 142 | 142 | setup_menu_entry("User Log", "access_log", |
| 143 | 143 | "A record of login attempts"); |
| 144 | 144 | setup_menu_entry("Administrative Log", "admin_log", |
| 145 | 145 | "View the admin_log entries"); |
| 146 | + setup_menu_entry("Error Log", "errorlog", | |
| 147 | + "View the Fossil server error log"); | |
| 146 | 148 | setup_menu_entry("Unversioned Files", "uvlist?byage=1", |
| 147 | 149 | "Show all unversioned files held"); |
| 148 | 150 | setup_menu_entry("Stats", "stat", |
| 149 | 151 | "Repository Status Reports"); |
| 150 | 152 | setup_menu_entry("Sitemap", "sitemap", |
| 151 | 153 |
| --- 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 |