This project has retired. For details please refer to its Attic page.
Source code
001package org.apache.archiva.web.api;
002/*
003 * Licensed to the Apache Software Foundation (ASF) under one
004 * or more contributor license agreements.  See the NOTICE file
005 * distributed with this work for additional information
006 * regarding copyright ownership.  The ASF licenses this file
007 * to you under the Apache License, Version 2.0 (the
008 * "License"); you may not use this file except in compliance
009 * with the License.  You may obtain a copy of the License at
010 *
011 * http://www.apache.org/licenses/LICENSE-2.0
012 *
013 * Unless required by applicable law or agreed to in writing,
014 * software distributed under the License is distributed on an
015 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
016 * KIND, either express or implied.  See the License for the
017 * specific language governing permissions and limitations
018 * under the License.
019 */
020
021import org.apache.archiva.web.model.JavascriptLog;
022import org.slf4j.Logger;
023import org.slf4j.LoggerFactory;
024import org.springframework.stereotype.Service;
025
026/**
027 * @author Olivier Lamy
028 * @since 1.4-M4
029 */
030@Service("javascriptLogger#default")
031public class DefaultJavascriptLogger
032    implements JavascriptLogger
033{
034    private Logger logger = LoggerFactory.getLogger( getClass() );
035
036    @Override
037    public Boolean trace( JavascriptLog javascriptLog )
038    {
039        Logger toUse =
040            javascriptLog.getLoggerName() == null ? logger : LoggerFactory.getLogger( javascriptLog.getLoggerName() );
041        if ( javascriptLog.getMessage() == null )
042        {
043            return Boolean.TRUE;
044        }
045        toUse.trace( javascriptLog.getMessage() );
046        return Boolean.TRUE;
047    }
048
049    @Override
050    public Boolean debug( JavascriptLog javascriptLog )
051    {
052        Logger toUse =
053            javascriptLog.getLoggerName() == null ? logger : LoggerFactory.getLogger( javascriptLog.getLoggerName() );
054
055        if ( javascriptLog.getMessage() == null )
056        {
057            return Boolean.TRUE;
058        }
059
060        toUse.debug( javascriptLog.getMessage() );
061        return Boolean.TRUE;
062    }
063
064    @Override
065    public Boolean info( JavascriptLog javascriptLog )
066    {
067        Logger toUse =
068            javascriptLog.getLoggerName() == null ? logger : LoggerFactory.getLogger( javascriptLog.getLoggerName() );
069
070        if ( javascriptLog.getMessage() == null )
071        {
072            return Boolean.TRUE;
073        }
074
075        toUse.info( javascriptLog.getMessage() );
076        return Boolean.TRUE;
077    }
078
079    @Override
080    public Boolean warn( JavascriptLog javascriptLog )
081    {
082        Logger toUse =
083            javascriptLog.getLoggerName() == null ? logger : LoggerFactory.getLogger( javascriptLog.getLoggerName() );
084
085        if ( javascriptLog.getMessage() == null )
086        {
087            return Boolean.TRUE;
088        }
089
090        toUse.warn( javascriptLog.getMessage() );
091        return Boolean.TRUE;
092    }
093
094    @Override
095    public Boolean error( JavascriptLog javascriptLog )
096    {
097        Logger toUse =
098            javascriptLog.getLoggerName() == null ? logger : LoggerFactory.getLogger( javascriptLog.getLoggerName() );
099
100        if ( javascriptLog.getMessage() == null )
101        {
102            return Boolean.TRUE;
103        }
104
105        toUse.error( javascriptLog.getMessage() );
106        return Boolean.TRUE;
107    }
108}