Commits

Sebastian Sdorra committed 21152ac

added release logging

Comments (0)

Files changed (6)

scm-core/src/main/java/sonia/scm/util/ServiceUtil.java

  *
  */
 
+
+
 package sonia.scm.util;
 
-//~--- non-JDK imports --------------------------------------------------------
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 //~--- JDK imports ------------------------------------------------------------
 
 import java.util.ArrayList;
 public class ServiceUtil
 {
 
-  /** Field description */
-  private static final Logger logger =
-    LoggerFactory.getLogger(ServiceUtil.class);
-
-  //~--- get methods ----------------------------------------------------------
-
   /**
    * Method description
    *
     }
     catch (NoSuchElementException ex)
     {
-      logger.debug(ex.getMessage(), ex);
+
+      // do nothing
     }
 
     return result;
     }
     catch (NoSuchElementException ex)
     {
-      logger.debug(ex.getMessage(), ex);
+
+      // do nothing
     }
 
     return result;

scm-webapp/pom.xml

       </plugin>
 
       <plugin>
+        <groupId>sonia.maven</groupId>
+        <artifactId>change-env</artifactId>
+        <version>1.0-SNAPSHOT</version>
+        <configuration>
+          <environment>${environment.profile}</environment>
+          <pattern>.*(\.{env})\.xml</pattern>
+        </configuration>
+        <executions>
+          <execution>
+            <phase>process-resources</phase>
+            <goals>
+              <goal>change-env</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+
+      <plugin>
         <groupId>org.mortbay.jetty</groupId>
         <artifactId>maven-jetty-plugin</artifactId>
         <version>6.1.26</version>
   </build>
 
   <properties>
+    <environment.profile>default</environment.profile>
     <aether.version>1.9</aether.version>
     <wagon.version>1.0-beta-7</wagon.version>
     <maven.version>3.0.2</maven.version>
 
         </plugins>
       </build>
+
+      <properties>
+        <environment.profile>release</environment.profile>
+      </properties>
     </profile>
 
     <profile>

scm-webapp/src/main/java/sonia/scm/ScmLogFilePropertyDefiner.java

+/**
+ * Copyright (c) 2010, Sebastian Sdorra
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ * 2. 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.
+ * 3. Neither the name of SCM-Manager; 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 REGENTS 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.
+ *
+ * http://bitbucket.org/sdorra/scm-manager
+ *
+ */
+
+
+
+package sonia.scm;
+
+//~--- non-JDK imports --------------------------------------------------------
+
+import ch.qos.logback.core.PropertyDefinerBase;
+
+//~--- JDK imports ------------------------------------------------------------
+
+import java.io.File;
+
+/**
+ *
+ * @author Sebastian Sdorra
+ */
+public class ScmLogFilePropertyDefiner extends PropertyDefinerBase
+{
+
+  /** Field description */
+  public static final String LOG_DIRECTORY = "logs";
+
+  //~--- constructors ---------------------------------------------------------
+
+  /**
+   * Constructs ...
+   *
+   */
+  public ScmLogFilePropertyDefiner()
+  {
+    File logDirectory = new File(SCMContext.getContext().getBaseDirectory(),
+                                 LOG_DIRECTORY);
+
+    if (!logDirectory.exists())
+    {
+      logDirectory.mkdirs();
+    }
+
+    this.logDirectoryPath = logDirectory.getAbsolutePath();
+  }
+
+  //~--- get methods ----------------------------------------------------------
+
+  /**
+   * Method description
+   *
+   *
+   * @return
+   */
+  @Override
+  public String getPropertyValue()
+  {
+    return logDirectoryPath;
+  }
+
+  //~--- fields ---------------------------------------------------------------
+
+  /** Field description */
+  private String logDirectoryPath;
+}

scm-webapp/src/main/resources/logback.default.xml

+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+    Document   : logback.xml
+    Created on : January 18, 2011, 5:46 PM
+    Author     : sdorra
+    Description:
+        Purpose of the document follows.
+-->
+
+<configuration>
+
+  <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+    <!-- encoders are  by default assigned the type
+         ch.qos.logback.classic.encoder.PatternLayoutEncoder -->
+    <encoder>
+      <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n</pattern>
+    </encoder>
+  </appender>
+
+  <logger name="sonia.scm" level="DEBUG" />
+  <logger name="sonia.scm.util.ServiceUtil" level="WARN" />
+
+  <root level="WARN">
+    <appender-ref ref="STDOUT" />
+  </root>
+  
+</configuration>

scm-webapp/src/main/resources/logback.release.xml

+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+    Document   : logback.release.xml
+    Created on : February 3, 2011, 6:36 PM
+    Author     : sdorra
+    Description:
+        Purpose of the document follows.
+-->
+
+<configuration>
+
+  <define name="LOGDIR" class="sonia.scm.ScmLogFilePropertyDefiner" />
+
+  <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
+    <file>${LOGDIR}/scm-manager.log</file>
+
+    <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
+      <fileNamePattern>scm-manager-%i.log</fileNamePattern>
+      <minIndex>1</minIndex>
+      <maxIndex>10</maxIndex>
+    </rollingPolicy>
+
+    <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
+      <maxFileSize>10MB</maxFileSize>
+    </triggeringPolicy>
+
+    <append>true</append>
+    <encoder>
+      <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n</pattern>
+    </encoder>
+  </appender>
+
+  <logger name="sonia.scm" level="INFO" />
+  <logger name="sonia.scm.util.ServiceUtil" level="WARN" />
+
+  <root level="WARN">
+    <appender-ref ref="FILE" />
+  </root>
+
+</configuration>

scm-webapp/src/main/resources/logback.xml

-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
-    Document   : logback.xml
-    Created on : January 18, 2011, 5:46 PM
-    Author     : sdorra
-    Description:
-        Purpose of the document follows.
--->
-
-<configuration>
-
-  <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
-    <!-- encoders are  by default assigned the type
-         ch.qos.logback.classic.encoder.PatternLayoutEncoder -->
-    <encoder>
-      <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n</pattern>
-    </encoder>
-  </appender>
-
-  <logger name="sonia.scm" level="DEBUG" />
-  <logger name="sonia.scm.util.ServiceUtil" level="WARN" />
-
-  <root level="WARN">
-    <appender-ref ref="STDOUT" />
-  </root>
-  
-</configuration>