Java Log Message log(String message, PrintStream out)

Here you can find the source of log(String message, PrintStream out)

Description

log

License

Open Source License

Declaration

public static void log(String message, PrintStream out) 

Method Source Code

//package com.java2s;
/**//from   ww w.  jav a 2  s . c  om
 * Copyright (c) 2014-2015 by Wen Yu.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Any modifications to this file must keep this entire header intact.
 */

import java.io.PrintStream;

public class Main {
    public static void log(String message, PrintStream out) {
        StackTraceElement se = Thread.currentThread().getStackTrace()[2];
        out.println("; " + message + " - [" + se.getClassName() + "." + se.getMethodName() + "(): line "
                + se.getLineNumber() + "]");
    }

    public static String getClassName(Class<?> c) {
        String name = c.getName().replace('$', '.');

        if (c.isArray()) {
            switch (name.charAt(1)) {
            case 'B':
                name = "byte";
                break;
            case 'C':
                name = "char";
                break;
            case 'D':
                name = "double";
                break;
            case 'F':
                name = "float";
                break;
            case 'I':
                name = "int";
                break;
            case 'J':
                name = "long";
                break;
            case 'L':
                name = name.substring(2, name.length() - 1);
                break;
            case 'S':
                name = "short";
                break;
            case 'Z':
                name = "boolean";
                break;
            }
            name = name + "[]";
        }

        return name;
    }
}

Related

  1. Log(String filename, String message)
  2. log(String fmt, Object... args)
  3. log(String line)
  4. log(String message)
  5. log(String message)
  6. log(String msg)
  7. LOG(String msg, PrintWriter writer)
  8. logLine(String filePath, String line)
  9. logMessage(String message)