//# 0 errors, 19 messages
//#
/*
    //#audittrail.java:1:1: class: net.sourceforge.pebble.audit.AuditTrail
 * Copyright (c) 2003-2006, Simon Brown
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 *   - Redistributions of source code must retain the above copyright
 *     notice, this list of conditions and the following disclaimer.
 *
 *   - Redistributions in binary form must reproduce the above copyright
 *     notice, this list of conditions and the following disclaimer in
 *     the documentation and/or other materials provided with the
 *     distribution.
 *
 *   - Neither the name of Pebble nor the names of its contributors may
 *     be used to endorse or promote products derived from this software
 *     without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */
package net.sourceforge.pebble.audit;

import net.sourceforge.pebble.util.SecurityUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * Used to log auditable events (e.g. publication, deletion of blog
 * entries, etc)
 *
 * @author    Simon Brown
 */
public class AuditTrail {
    //#audittrail.java:44: method: void net.sourceforge.pebble.audit.AuditTrail.net.sourceforge.pebble.audit.AuditTrail()
    //#audittrail.java:44: end of method: void net.sourceforge.pebble.audit.AuditTrail.net.sourceforge.pebble.audit.AuditTrail()

  /** the log used by this class */
  private static Log log = LogFactory.getLog(AuditTrail.class);
    //#audittrail.java:47: method: net.sourceforge.pebble.audit.AuditTrail.net.sourceforge.pebble.audit.AuditTrail__static_init
    //#audittrail.java:47: Warning: method not available
    //#    -- call on Log org.apache.commons.logging.LogFactory:getLog(Class)
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.audit.AuditTrail
    //#    method: net.sourceforge.pebble.audit.AuditTrail__static_init
    //#    unanalyzed callee: Log org.apache.commons.logging.LogFactory:getLog(Class)
    //#output(net.sourceforge.pebble.audit.AuditTrail__static_init): __Descendant_Table[net/sourceforge/pebble/audit/AuditTrail]
    //#output(net.sourceforge.pebble.audit.AuditTrail__static_init): log
    //#post(net.sourceforge.pebble.audit.AuditTrail__static_init): __Descendant_Table[net/sourceforge/pebble/audit/AuditTrail] == &__Dispatch_Table
    //#post(net.sourceforge.pebble.audit.AuditTrail__static_init): init'ed(log)
    //#audittrail.java:47: end of method: net.sourceforge.pebble.audit.AuditTrail.net.sourceforge.pebble.audit.AuditTrail__static_init

  public static void log(String event) {
    String username = SecurityUtils.getUsername();
    //#audittrail.java:50: method: void net.sourceforge.pebble.audit.AuditTrail.log(String)
    //#audittrail.java:50: Warning: method not available
    //#    -- call on String net.sourceforge.pebble.util.SecurityUtils:getUsername()
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.audit.AuditTrail
    //#    method: void log(String)
    //#    unanalyzed callee: String net.sourceforge.pebble.util.SecurityUtils:getUsername()
    //#input(void log(String)): event
    //#input(void log(String)): log
    //#pre[2] (void log(String)): log != null
    //#test_vector(void log(String)): net.sourceforge.pebble.util.SecurityUtils:getUsername(...)@50: Inverse{null}, Addr_Set{null}
    if (username == null) {
      username = "anonymous";
    }

    log.info(username + " : " + event);
    //#audittrail.java:55: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:info(Object)
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.audit.AuditTrail
    //#    method: void log(String)
    //#    unanalyzed callee: void org.apache.commons.logging.Log:info(Object)
  }
    //#audittrail.java:56: end of method: void net.sourceforge.pebble.audit.AuditTrail.log(String)

}
    //#audittrail.java:: end of class: net.sourceforge.pebble.audit.AuditTrail
