def FormatLogMessage(msg,context,level):
    """
    Generic log message formatter.
    This is a crude initial attempt:  I'm sure we could do much better.

    msg     - is message to be logged
    context - is a string describing the source of the message
              (can be used for filtering)
    level   - indicates the message severity: 
              0 - diagnostic, 1 - warning, 2 - error
    """
    if level == 0:
        leveltag = "TRACE"
    elif level == 1:
        leveltag = "INFO"
    elif level == 2:
        leveltag = "WARNING"
    elif level == 3:
        leveltag = "ERROR"
    else:
        leveltag = "UKNOWN"
    if context:
        context = context+": "
    return "%s%s - %s" % (context,leveltag,msg)