Skip to content

Suggestion : clear the trace folder #1

Description

@cavo789

Hello

Small suggestion : next to the Load button, add a "clear folder" button so the user can empty the trace folder.

In a very quick (and probably dirty) addition, I suggest to add something like this at the top of your file

	$dir = ini_get('xdebug.trace_output_dir');
	if (!$dir) $dir = '/tmp/';
	if (isset($_GET['task'])) {

	if ($_GET['task']==='empty') 
	{
		$files = glob("$dir/*.xt");
		$return='';
		if (count($files)>0) {
			foreach ($files as $file) 
			{
				$return.=$file.'|';
				unlink($file);
			}
		}
		echo $return;
		die();
	} else {

		$btnEmpty="<button id='emptyfolder'>Empty trace folder</button>".
		"<script>\n".
		"   $('#emptyfolder').click(function (e) {\n".
		"      e.preventDefault();\n".
		"      $.ajax({\n".
		"      url: 'index.php?task=empty'\n".
		"      }).done(function() {\n".
		"         alert('Files in $dir have been removed');\n".
		"      });\n".
		"   });\n".
		"</script>\n";
	}

This will erase every .xt files (when ?task=empty is specified on the querystring).

Otherwise will initialize a $btnEmpty button.

In your html, next to the load button, just echo $btnEmpty.

Have a nice day.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions