Changeset 1837


Ignore:
Timestamp:
2001-01-15T15:21:43+13:00 (23 years ago)
Author:
sjboddie
Message:

Made a few cosmetic changes to the "Administration" pages and added the
ability to view the last 100 lines of the usage log. This meant making a
change to the file_tail() function to allow for the very long lines that
occur in the log file.

Location:
trunk/gsdl
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/lib/fileutil.cpp

    r1815 r1837  
    337337}
    338338
    339 // This is a fairly quick and nasty attempt at doing a "tail" on
    340 // a file (i.e. returning the last numlines lines of filename).
    341 // It has one important limitation in that it expects lines to be
    342 // 256 characters long on average.
    343 // This of course makes it possible that it won't return numlines
    344 // lines if there are some very long lines.
    345 // It also makes it fairly inefficient as it always reads in
    346 // numlines*256 characters which is much more than generally
    347 // necessary.
     339// This is a fairly quick and nasty attempt at doing a "tail" on a file
     340// (i.e. returning the last numlines lines of filename).  It has one
     341// important limitation in that it expects lines to be linelength
     342// characters long on average.  This of course makes it possible that it
     343// won't return numlines lines if there are some lines that are longer than
     344// linelength.  It also makes it fairly inefficient as it always reads in
     345// numlines*linelength characters when it most often doesn't need them all.
    348346// For current needs it's fine though.
    349 text_t file_tail (const text_t &filename, int numlines) {
     347// -- Pass a linelength of 0 to use the default linelength (256 chars).
     348text_t file_tail (const text_t &filename, int numlines, int linelength) {
    350349
    351350  if (numlines < 1) numlines = 1;
    352   streampos numchars = 256*numlines;
     351  if (linelength == 0) linelength = 256;
     352 
     353  streampos numchars = linelength*numlines;
    353354
    354355  text_tarray lines;
     
    356357
    357358  char *filenamec = filename.getcstr();
    358   char linec[256];
     359  char linec[linelength];
    359360  ifstream file_in (filenamec);
    360361  delete filenamec;
     
    366367
    367368    while (!file_in.eof()) {
    368       file_in.getline (linec, 256);
     369      file_in.getline (linec, linelength);
    369370      ret.setcstr(linec);
    370371      text_t::const_iterator here = ret.begin();
  • trunk/gsdl/lib/fileutil.h

    r1739 r1837  
    5656bool file_copy (const text_t &fromfile, const text_t &tofile);
    5757
    58 text_t file_tail (const text_t &filename, int numlines);
     58text_t file_tail (const text_t &filename, int numlines, int linelength);
    5959
    6060// returns true if directory created successfully
  • trunk/gsdl/macros/status.dm

    r1796 r1837  
    6464<a href="_httppagehome_" target=\_top>_textreturnhome_</a>
    6565
     66<p><b>_textconfigfiles_</b><br>
     67<a href="_gwcgi_?e=_compressedoptions_&a=status&p=gsdlsite" target=infoframe>_textgsdlsite_</a><br>
     68<a href="_gwcgi_?e=_compressedoptions_&a=status&p=maincfg" target=infoframe>_textmaincfg_</a>
     69
     70<p><b>_textlogs_</b><br>
     71<a href="_gwcgi_?e=_compressedoptions_&a=status&p=usagelog" target=infoframe>_textusagelog_</a><br>
     72<a href="_gwcgi_?e=_compressedoptions_&a=status&p=initlog" target=infoframe>_textinitlog_</a><br>
     73<a href="_gwcgi_?e=_compressedoptions_&a=status&p=errorlog" target=infoframe>_texterrorlog_</a>
     74
    6675_If_("_cgiarguma_" ne "\_cgiarguma\_",
    6776<p><b>_textusermanage_</b><br>
     
    7786<a href="_gwcgi_?e=_compressedoptions_&a=status&p=browserinfo" target=infoframe>_textbrowsers_</a><br>
    7887<a href="_gwcgi_?e=_compressedoptions_&a=status&p=protocolinfo" target=infoframe>_textprotocols_</a>
    79 
    80 <p><b>_textconfigfiles_</b><br>
    81 <a href="_gwcgi_?e=_compressedoptions_&a=status&p=gsdlsite" target=infoframe>_textgsdlsite_</a><br>
    82 <a href="_gwcgi_?e=_compressedoptions_&a=status&p=maincfg" target=infoframe>_textmaincfg_</a>
    83 
    84 <p><b>_textlogs_</b><br>
    85 <a href="_gwcgi_?e=_compressedoptions_&a=status&p=initlog" target=infoframe>_textinitlog_</a><br>
    86 <a href="_gwcgi_?e=_compressedoptions_&a=status&p=errorlog" target=infoframe>_texterrorlog_</a>
    8788}
    8889
     
    9495_textchangepasswd_ {change password}
    9596
    96 _textinfo_ {Information}
     97_textinfo_ {Technical information}
    9798_textgeneral_ {general}
    9899_textarguments_ {arguments}
     
    106107
    107108_textlogs_ {Logs}
     109_textusagelog_ {usage log}
    108110_textinitlog_ {init log}
    109111_texterrorlog_ {error log}
     
    112114_textreturnhome_ {Greenstone home}
    113115
    114 _titlewelcome_ { Maintenance and Administration }
     116_titlewelcome_ { Administration }
    115117
    116118_welcome_ {
  • trunk/gsdl/src/recpt/collectoraction.cpp

    r1821 r1837  
    806806  if (file_exists (bld_file + ".download")) {
    807807    statusline = "Downloading files ...<br>\n";
    808     statusline += file_tail (bld_file + ".download", 1);
     808    statusline += file_tail (bld_file + ".download", 1, 0);
    809809  } else if (file_exists (bld_file + ".import")) {
    810810    statusline = "Importing collection ...<br>\n";
    811     statusline += file_tail (bld_file + ".import", 1);
     811    statusline += file_tail (bld_file + ".import", 1, 0);
    812812  } else if (file_exists (bld_file + ".build")) {
    813813    statusline = "Building collection ...<br>\n";
    814     statusline += file_tail (bld_file + ".build", 1);
     814    statusline += file_tail (bld_file + ".build", 1, 0);
    815815  } else {
    816816    statusline += "creating collection ...<br>\n";
    817     statusline += file_tail (bld_file, 1);
     817    statusline += file_tail (bld_file, 1, 0);
    818818  }
    819819
     
    957957  if (collector_page == "bildfail") {
    958958    text_t bldlog = filename_cat(gsdlhome, "tmp", args["bc1tmp"], args["bc1dirname"] + ".bld");
    959     text_t rawlog = file_tail (bldlog, 6);
     959    text_t rawlog = file_tail (bldlog, 6, 0);
    960960    // we'll shove in some <br> tags where \n's occur
    961961    text_t faillog;
  • trunk/gsdl/src/recpt/statusaction.cpp

    r1801 r1837  
    742742}
    743743
     744void statusaction::output_usagelog (cgiargsclass &/*args*/, displayclass &disp,
     745                    outconvertclass &outconvert,
     746                    ostream &textout, ostream &/*logout*/) {
     747
     748  // output last 100 lines of usage.txt
     749
     750  text_t logfilename = filename_cat (gsdlhome, "etc", "usage.txt");
     751
     752  textout << outconvert << disp << "_status:infoheader_(Usage log)\n";
     753  textout << outconvert << "<h2>Usage log</h2>\n";
     754
     755  textout << outconvert << "<p>The usage log, "
     756      << logfilename << ", contains the\n"
     757      << "following information:\n"
     758      << "<p>(note that if this file is more than 100 lines long only the last 100 lines will\n"
     759      << "be displayed on this page)\n\n"
     760      << "<pre>\n";
     761
     762  // note that we're expecting lines to be no more than 1500 characters on
     763  // average - should fix this file_tail() thing sometime
     764  textout << outconvert << file_tail (logfilename, 100, 1500);
     765
     766  textout << outconvert << disp << "</pre>\n"
     767      << "_status:infofooter_\n";
     768}
     769
    744770void statusaction::output_initlog (cgiargsclass &/*args*/, displayclass &disp,
    745771                   outconvertclass &outconvert,
     
    762788  if (initin) {
    763789    textout << outconvert << "<p>The initialisation error log, "
    764         << initfilename << ", contains the\n";
     790        << initfilename << ", contains the\n";
    765791    textout << outconvert << "following information:\n\n";
    766792    text_t errorpage = "<p><pre>\n";
     
    779805  } else {
    780806    textout << outconvert << "Couldn't read initialisation error log, "
    781         << initfilename << ".\n";
     807        << initfilename << ".\n";
    782808  }
    783809
     
    11071133  else if (arg_p == "protocolinfo") output_protocolinfo (args, disp, outconvert, textout, logout);
    11081134  else if (arg_p == "collectioninfo") output_collectioninfo (args, disp, outconvert, textout, logout);
     1135  else if (arg_p == "usagelog") output_usagelog (args, disp, outconvert, textout, logout);
    11091136  else if (arg_p == "initlog") output_initlog (args, disp, outconvert, textout, logout);
    11101137  else if (arg_p == "errorlog") output_errorlog (args, disp, outconvert, textout, logout);
  • trunk/gsdl/src/recpt/statusaction.h

    r1794 r1837  
    7575                  ostream &textout, ostream &logout);
    7676
     77  void output_usagelog (cgiargsclass &args, displayclass &disp,
     78            outconvertclass &outconvert,
     79            ostream &textout, ostream &logout);
     80
    7781  void output_initlog (cgiargsclass &args, displayclass &disp,
    7882               outconvertclass &outconvert,
Note: See TracChangeset for help on using the changeset viewer.