Tuesday, May 15, 2007

stoken-utils - AppInfo for build number automation

Overview
In my mind there needs to be a simple way to automate build numbers within a project. The stoken-utils project is handy for helping with this using features of ANT and JAVA. It is a small portable library that, among other thing, helps manage project level build numbers.

Project Information
stoken-utils can be downloaded here. You may also find the logger feature of this library also interesting.

Usage
I have already blogged about this approach here. In a nutshell, usage is not to complex.
  • Add a small XML stub to your build.xml
  • Modify it with your project specifics (name, description, copyright,....)
  • Load appinfo.properties via AppInfo.init(...) see javadoc.
  • Access values using AppInfo static methods.
To look at some code that uses this libarary check out the subversion tab of language-translate.

Final Thoughts
stoken-utils has a simple approach for managing build numbers using ANT and JAVA.

Monday, April 16, 2007

stoken-utils logger

Overview
On occasion a simple logger comes in handy. Granted log4j rules and will solve all your enterprise level logging needs, but in some cases, you just want something written to a file with minimal fuss. That is where the the logger comes in. It is part of a small library of utilities called stoken-utils.

Project Information
Download: http://code.google.com/p/stoken-utils/

Usage
Using logger is easy. There are several overloaded static methods. The one with the most options is as follows:
public static boolean writeLog(
String PROGNAME,
String MODULE,
TYPE type,
String msg,
boolean addblank
);
PROGNAME - name of your program (or AppInfo.getPROGNAME())
MODULE - usually CLASSNAME::METHOD for me but this is free form.
TYPE - Logger.TYPE enum of Debug, Warn, Error, ....
msg - log message in freeform text.
addblank - adds a blank line after this log message. Usually used before your program shutdown.

The overloaded versions are all described in the javadoc which is downloadable as a zip.

Example
The following
Logger.writeLog("PROGNAME","CLASS::METHOD",TYPE.Debug,"Message",false);
You will end up with a file called PROGNAME.log with the following values:

2007-04-14 00:37:13 [Debug](CLASS::METHOD) Message
File Location
The location where the log files are written can be controlled using several static members.
LOG_FILE_DIR - path to log location like /tmp/logs
LOG_BACKUP_DIR - subdirectory where backups are automatically written (default is "backuplogs/")
LOG_FILE_EXT - extension to add to log file name. (default is ".log")

Behavior

When using Logger, you can expect it to create a backup of your log each day. The backups are placed in the directory pointed to by LOG_BACKUP_DIR. The current log will be appended to always so no data is lost.

I personally like to create a constant in each class called CLASSNAME and a second constant in each method called METHOD. For my MODULE parameter, I can then pass CLASSNAME + "::" + METHOD each time I want to write a log line.

Final Thoughts
I have found this logger to be useful and have used it in many projects (big and small).

Wednesday, March 28, 2007

Introduction

Now and then I have various projects I work on. Most of them are technical (programming typically). I plan on using this as a bit of a journal describing my project, their status, and any things that may come up as I complete them.

Expect an occasional rant to :-)