Today I am going to share one of my debugging experiences.
My code is as follows, It will simply write few columns of text data to a file, with COLUMN_SEPRATOR as “|” (pipe)
VLRerrorLog.write(msisdn);
VLRerrorLog.write(COLUMN_SEPRATOR);
VLRerrorLog.write(vlrID);
VLRerrorLog.write(COLUMN_SEPRATOR);
VLRerrorLog.write(cellID == null ? "null" : cellID);
VLRerrorLog.write(COLUMN_SEPRATOR);
VLRerrorLog.write(locID== null ? "null" : locID);
VLRerrorLog.write(COLUMN_SEPRATOR);
VLRerrorLog.write(timestampFormat.format(timeStamp));
VLRerrorLog.write(COLUMN_SEPRATOR);
VLRerrorLog.write(statusMsg);
VLRerrorLog.newLine();
Where VLRerrorLog is the Object of java.io.BufferedWriter
Following is the expected output
9665xxxxxxxx|9665xxxxxxxx|20894|2302|24/05/2011 13:28:32|SUCCESS
9665xxxxxxxx|9665xxxxxxxx|10632|1329|24/05/2011 13:29:19|SUCCESS
But when I peep into the file with tail –f (sorry to Windows folks, if you can’t get it)
|2302|24/05/2011 13:28:32|SUCCESS
|1329|24/05/2011 13:29:19|SUCCESS
(Missing first 3 columns in output)
Following are the few sparks on my mind
If any exception is happening, it should be missing the last columns not the first columns.
- If the data is something wrong it should print at least COLUMN_SEPRATOR “|” for the first 3 columns.
- If something wrong with file opening it should be OK with second line onwards.
- ................
You might have guessed what will be going wrong here, didn't you?
Guess it? (Guesses can provide in comments)