Commits

Hector Miuler Malpica Gallegos committed 0de00ed

agregando configuracion de log y capturando el texto entrante

Comments (0)

Files changed (3)

src/main/resources/logback.xml

+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- For assistance related to logback-translator or configuration  -->
+<!-- files in general, please contact the logback user mailing list -->
+<!-- at http://www.qos.ch/mailman/listinfo/logback-user             -->
+<!--                                                                -->
+<!-- For professional support please see                            -->
+<!--    http://www.qos.ch/shop/products/professionalSupport         -->
+<!--                                                                -->
+<configuration>
+    <!-- Errors were reported during translation. -->
+    <!-- No root logger configuration was found -->
+    <appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
+        <encoder>
+            <pattern>%d{MMM dd, HH:mm:ss} [%p] - [%t] - %c.%M\(%F:%L\) %m %n</pattern>
+        </encoder>
+    </appender>
+    <appender name="logfile" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <!--See http://logback.qos.ch/manual/appenders.html#RollingFileAppender-->
+        <!--and http://logback.qos.ch/manual/appenders.html#TimeBasedRollingPolicy-->
+        <!--for further documentation-->
+        <File>dsm-webapp.log</File>
+        <MaxFileSize>1024KB</MaxFileSize>
+        <MaxBackupIndex>5</MaxBackupIndex>
+        <encoder>
+            <pattern>%d{MMM dd, HH:mm:ss} [%p] - [%t] - %c.%M\(%F:%L\) %m %n</pattern>
+        </encoder>
+    </appender>
+    <!--<logger name="com.dsm.org" level="DEBUG">-->
+        <!--<appender-ref ref="stdout"/>-->
+        <!--<appender-ref ref="logfile"/>-->
+    <!--</logger>-->
+    <root level="DEBUG">
+        <appender-ref ref="stdout" />
+    </root>
+</configuration>

src/main/scala/com/miuler/mocksmtp/core/MockSMTP.scala

 import io.netty.channel._
 import io.netty.channel.socket.SocketChannel
 import io.netty.buffer.ByteBuf
+import io.netty.util.CharsetUtil
 
 /**
  * Created with IntelliJ IDEA.
 
   def start = {
 
-    class ChannelHandlerBasic extends ChannelInboundByteHandlerAdapter {
+    class ChannelInboundHandlerBasic extends ChannelInboundByteHandlerAdapter {
       def inboundBufferUpdated(ctx: ChannelHandlerContext, in: ByteBuf) {
-        log.info("ctx :{}   in: {}", ctx, in)
-        log.info("ctx.hasInboundByteBuffer: {}", ctx.hasInboundByteBuffer)
-        log.info("ctx.hasInboundMessageBuffer: {}", ctx.hasInboundMessageBuffer)
+        val decoder = CharsetUtil.getDecoder(CharsetUtil.UTF_8)
+        val instr = decoder.decode(in.nioBuffer())
+        log.debug("mensage: \n{}", instr)
+        in.clear()
       }
     }
 
+//    class ChannelOutboundHandlerBasic extends ChannelOutboundByteHandlerAdapter {
+//    }
+
+    log.debug("new server")
     server = new ServerBootstrap()
       .group(new NioEventLoopGroup())
       .channel(classOf[NioServerSocketChannel])
       .childHandler(
         new ChannelInitializer[SocketChannel]() {
           def initChannel(ch: SocketChannel) {
-            log.debug("initChannel ch: {}", ch)
             ch.pipeline()
-              .addLast("handlerIn", new ChannelHandlerBasic)
+              .addLast("handlerIn", new ChannelInboundHandlerBasic)
           }
         })
-    server.bind()
+    server.bind().sync()
   }
 
   def stop = server.shutdown()

src/main/scala/com/miuler/mocksmtp/gui/MainGUI.scala

 import com.miuler.mocksmtp.core.MockSMTP
 import org.slf4j.LoggerFactory
 import com.miuler.mocksmtp.utils.Utils.{stack2String, showMessageE}
+import java.net.SocketException
 
 
 /**
       }
     } catch {
       case e: Exception => {
-        log error stack2String(e)
+        log.error("Error al iniciar servidor SMTP", e)
         showMessageE(e)
       }
     }