PageRenderTime 47ms CodeModel.GetById 41ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/jEdit/tags/jedit-4-3-pre5/macros/Misc/Make_Bug_Report.bsh

#
Unknown | 118 lines | 108 code | 10 blank | 0 comment | 0 complexity | 7e51f0d8807d362ce4e173e6324e1bbc MD5 | raw file
  1/*
  2 * Make_Bug_Report.bsh - a BeanShell macro script for the
  3 * jEdit text editor -  creates a new buffer with installation and
  4 * error information extracted from jEdit's Activity Log.
  5 * Copyright (C) 2001 John Gellene
  6 * jgellene@nyc.rr.com
  7 * http://community.jedit.org
  8 *
  9 * This program is free software; you can redistribute it and/or
 10 * modify it under the terms of the GNU General Public License
 11 * as published by the Free Software Foundation; either version 2
 12 * of the License, or any later version.
 13 *
 14 * This program is distributed in the hope that it will be useful,
 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 17 * GNU General Public License for more details.
 18 *
 19 * You should have received a copy of the GNU General Public License
 20 * along with this program; if not, write to the Free Software
 21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 22 *
 23 * $Id: Make_Bug_Report.bsh 3873 2001-11-06 17:57:35Z jgellene $
 24 *
 25 * Checked for jEdit 4.0 API
 26 *
 27 */
 28
 29makeBugReport()
 30{
 31	Log.flushStream();
 32	path = jEdit.getSettingsDirectory() + File.separator
 33		+ "activity.log";
 34	try
 35	{
 36		file = new FileInputStream(path);
 37		reader = new BufferedReader(new InputStreamReader(file));
 38	}
 39	catch(IOException e)
 40	{
 41		Macros.error(view, "Error opening Activity Log.");
 42		return;
 43	}
 44	report = new StringBuffer();
 45
 46	report.append("Activity log entries that might be useful in a bug report:\n\n");
 47
 48	lastError = new StringBuffer();
 49	insideError = false;
 50	startupDone = false;
 51	activityLogHeaderLines = 9;
 52	try
 53	{
 54		for(i = 0; i < activityLogHeaderLines; ++i)
 55		{
 56			report.append(reader.readLine()).append('\n');
 57		}
 58		while((line = reader.readLine()) != null)
 59		{
 60			if(!startupDone &&
 61				(line.startsWith("[message] jEdit:")
 62					|| line.startsWith("[notice] jEdit:")
 63					|| line.startsWith("[notice] JARClassLoader:")))
 64			{
 65				report.append(line).append('\n');
 66				if(line.equals("[message] jEdit: Startup complete"))
 67				{
 68					startupDone = true;
 69				}
 70			}
 71			else if(line.startsWith("[error]"))
 72			{
 73				if(!insideError)
 74				{
 75					lastError.setLength(0);
 76					insideError = true;
 77				}
 78				lastError.append(line).append('\n');
 79			}
 80			else
 81				insideError = false;
 82		}
 83		reader.close();
 84	}
 85	catch(IOException e)
 86	{
 87		Macros.error(view, "Error reading Activity Log");
 88	}
 89
 90	report.append(lastError.toString());
 91	newBuffer = jEdit.newFile(view);
 92	newBuffer.insert(0, report.toString());
 93}
 94
 95makeBugReport();
 96
 97/*
 98jEdit macro index data (DocBook format)
 99
100  <listitem>
101    <para><filename>Make_Bug_Report.bsh</filename></para>
102    <abstract><para>
103      Creates a new buffer with installation and error information
104	  extracted from the Activity Log.
105    </para></abstract>
106	<para>
107	  The macro extracts initial messages written to the Activity Log
108	  describing the user's operating system, JDK, jEdit version and
109	  installed plugins. It then appends the last set of error messages
110	  written to the Activity Log.  The new text buffer can be saved and
111	  attached to an email message or a bug report made on SourceForge.
112	</para>
113  </listitem>
114
115*/
116
117// end Make_Bug_Report.bsh
118