001/*
002 * (C) Copyright 2015 Nuxeo SA (http://nuxeo.com/) and contributors.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the GNU Lesser General Public License
006 * (LGPL) version 2.1 which accompanies this distribution, and is available at
007 * http://www.gnu.org/licenses/lgpl-2.1.html
008 *
009 * This library is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012 * Lesser General Public License for more details.
013 *
014 * Contributors:
015 *     Anahide Tchertchian
016 */
017package org.nuxeo.runtime.logging;
018
019import org.apache.commons.lang.StringUtils;
020import org.apache.commons.logging.Log;
021import org.apache.commons.logging.LogFactory;
022import org.nuxeo.runtime.api.Framework;
023
024/**
025 * Logger for deprecation warnings.
026 * <p>
027 * Can be activated only when dev mode is set, and can hold the version from which deprecation starts.
028 *
029 * @since 7.4
030 */
031public class DeprecationLogger {
032
033    private static final Log log = LogFactory.getLog(DeprecationLogger.class);
034
035    public static final void log(String message, String deprecatedVersion) {
036        StringBuilder finalMessage = new StringBuilder();
037        if (!StringUtils.isBlank(deprecatedVersion)) {
038            finalMessage.append("Since version ").append(deprecatedVersion).append(": ");
039        }
040        finalMessage.append(message);
041        log(finalMessage.toString());
042    }
043
044    public static final void log(String message) {
045        if (Framework.isDevModeSet()) {
046            log.warn(message);
047        }
048    }
049
050}