// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

package com.microsoft.aspnet.signalr;

public class ConsoleLogger implements Logger {
    private LogLevel logLevel;
    public ConsoleLogger(LogLevel logLevel) {
            this.logLevel = logLevel;
    }

    @Override
    public void log(LogLevel logLevel, String message) {
        if(logLevel.value >= this.logLevel.value){
            switch (logLevel) {
                case Debug:
                case Information:
                    System.out.println(message);
                    break;
                case Warning:
                case Error:
                case Critical:
                    System.err.println(message);
                    break;
            }
        }
    }

    @Override
    public void log(LogLevel logLevel, String formattedMessage, Object... args) {
        if (logLevel.value >= this.logLevel.value) {
            formattedMessage = formattedMessage + "%n";
            switch (logLevel) {
                case Debug:
                case Information:
                    System.out.printf(formattedMessage, args);
                    break;
                case Warning:
                case Error:
                case Critical:
                    System.err.printf(formattedMessage, args);
                    break;
            }
        }
    }
}

@@ -204,85 +204,255 @@
 r;%0A%0A
-public class ConsoleLogger implements Logger %7B%0A    private LogLevel logLevel;
+import java.text.DateFormat;%0Aimport java.text.SimpleDateFormat;%0Aimport java.util.Date;%0A%0Apublic class ConsoleLogger implements Logger %7B%0A    private LogLevel logLevel;%0A    private DateFormat dateFormat = new SimpleDateFormat(%22yyyy-MM-dd'T'HH:mmZ%22);%0A
 %0A   
@@ -661,16 +661,161 @@
 value)%7B%0A
+            String timeStamp = dateFormat.format(new Date());%0A            message = String.format(%22%5B%25s%5D %5B%25s%5D %25s%22, timeStamp, logLevel, message);%0A
         
@@ -1337,26 +1337,141 @@
     
-formattedMessage =
+String timeStamp = dateFormat.format(new Date());%0A            formattedMessage = String.format(%22%5B%25s%5D %5B%25s%5D %25s%25n%22, timeStamp, logLevel,
  for
@@ -1487,15 +1487,9 @@
 sage
- + %22%25n%22
+)
 ;%0A  

Add timestamps to log messages (#2777)