001/*
002 * Licensed to DuraSpace under one or more contributor license agreements.
003 * See the NOTICE file distributed with this work for additional information
004 * regarding copyright ownership.
005 *
006 * DuraSpace licenses this file to you under the Apache License,
007 * Version 2.0 (the "License"); you may not use this file except in
008 * compliance with the License.  You may obtain a copy of the License at
009 *
010 *     http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018package org.fcrepo.audit;
019
020import static org.slf4j.LoggerFactory.getLogger;
021
022import javax.annotation.PostConstruct;
023import javax.inject.Inject;
024
025import org.fcrepo.kernel.api.observer.FedoraEvent;
026
027import org.slf4j.Logger;
028
029import com.google.common.eventbus.EventBus;
030import com.google.common.eventbus.Subscribe;
031
032/**
033 * A proof-of-concept Auditor implementation that uses Logback.
034 *
035 * @author Edwin Shin
036 * @since 2014
037 */
038public class LogbackAuditor implements Auditor {
039
040    /**
041     * Logger for this class.
042     */
043    private static final Logger LOGGER = getLogger(LogbackAuditor.class);
044
045    @Inject
046    private EventBus eventBus;
047
048    /**
049     * Register with the EventBus to receive events.
050     */
051    @PostConstruct
052    public void register() {
053        LOGGER.debug("Initializing: {}", this.getClass().getCanonicalName());
054        eventBus.register(this);
055    }
056
057    @Override
058    @Subscribe
059    public void recordEvent(final FedoraEvent e) {
060        LOGGER.info("{} {}", e.getUserID(), e.getPath());
061    }
062}