Tuesday, February 22, 2011

Using Notepad++ to make Apex Test Runner Debug output readable

When running the Apex Test Runner in Eclipse with the Log level set to Debug it can be difficult to see your debug messages through the noise of method entry and method exit messages.

Notepad++

I've been copying the output into Notepad++ and then using the RegExs ^.+METHOD_.+$ and ^.+CONSTRUCTOR_.+$ followed by[ TextFX > TextFX Edit > Delete Blank Lines] to clean up the output.

With v5.8.7 I was able to combine all this into a Macro.

Visual Studio 2010

Better yet, copy it into a Visual Studio 2010 txt file and add a \n to the end of each regex.

Eclipse

Another good option is to adjust the amount of logging that occurs in the first place. See Setting Debug Log Filters

System Log | Force.com Console | Developer Console

The online logging has come a long way since this was first posted. Assuming the log isn't too big you can now Filter the execution log directly online.

See also:

Monday, February 21, 2011

Nelson .NET User Group Presentation - Using Powershell to aide builds and deployments

Upcoming meeting

This presentation is coming up next week. Please let me know if you are planning of attending.

Title:

Using Powershell to aide builds and deployments

Abstract:

Windows PowerShell is a powerful scripting framework and command line shell provided by Microsoft, and in a windows development environment is a natural candidate to integrate with your builds and deployments. Stepping through some of the basics of source and build management in Team Foundation Server it will be shown how you can easily extend your development environment using PowerShell to automate some of the more mundane and error prone tasks.

Giveaways:

I have a copy of Windows 7 Ultimate (64-bit) to give away during the presentation.
The winner will be selected through a random draw.

Useful links:

When:
Tuesday 1st March 2011
Gather at 11:50 am, starting at 12:00 pm.
Approximately 1 hour plus pizza afterwards.

Where:
FuseIT Ltd,
Ground Floor,
7 Forests Rd,
Stoke,
Nelson
(Off Nayland Rd and behind Carters)

http://local.live.com/default.aspx?v=2&cp=-41.299774~173.236231&style=r&lvl=16&alt=-1000
or
http://maps.google.com/?ie=UTF8&om=1&z=17&ll=-41.299774,173.236231&spn=0.005239,0.010042&t=h

If you are parking on site, please use the parks marked FuseIT that are at the back of the site.

Catering: Pizza & Drinks
Door Charge: Free

RSVP to me if you are going to attend so I can guesstimate the food and drink requirements.

However, feel free to turn up on the day though if you can't commit at the moment.

Please feel free to invite anyone who may be interested in attending.

Wednesday, February 9, 2011

Removing a log4net log file with a custom uninstaller

After creating a Windows Installer Setup Project to install a basic forms application demo application testing found that the program files directory that the installer created was not removed due to a log file that was created by log4net.

To resolve the issue a Installer Class was added to the winforms project with an override for Uninstall. Adding the custom Installer class to the existing project ensures that is was included in the Application Folder for the target machines File System without bringing in another DLL.

[RunInstaller(true)]
 public partial class Installer1 : System.Configuration.Install.Installer
 {
  public Installer1()
  {
   InitializeComponent();
  }

  [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand)]
  public override void Uninstall(IDictionary savedState)
  {
   base.Uninstall(savedState);

   //This is handy if you need to attach the debugger to the custom install action.
   //System.Diagnostics.Debugger.Break();

   try
   {
    string basePath = this.Context.Parameters["assemblyPath"];

    string baseDirectory = Path.GetDirectoryName(basePath);

    string logFilePath = Path.Combine(baseDirectory, "testapp.log");
    if (File.Exists(logFilePath))
    {
     File.Delete(logFilePath);
    }
   }
   catch
   {
    //Failed to delete the log file
   }

  }

 }

Finally the custom Uninstall implementation is connected to the Windows Installer.