Хостинг серверов Minecraft playvds.com
  1. Вы находитесь в русском сообществе Bukkit. Мы - администраторы серверов Minecraft, разрабатываем собственные плагины и переводим на русский язык плагины наших собратьев из других стран.
    Скрыть объявление

Решено Отключение логирования сессии в FORGE

Тема в разделе "[Архив] Помощь", создана пользователем МАРАЗМ, 16 авг 2013.

  1. Автор темы
    МАРАЗМ

    МАРАЗМ Активный участник Пользователь

    Баллы:
    88
    Skype:
    kolyadun3
    Имя в Minecraft:
    Mapa3m1
    Ребят помогите отключить логирование forge! Что откуда удалить?
    FMLrelauncher
    package cpw.mods.fml.relauncher;

    import java.applet.Applet;
    import java.io.File;
    import java.lang.reflect.Method;
    import java.net.URLClassLoader;

    import javax.swing.JDialog;
    import javax.swing.JOptionPane;

    public class FMLRelauncher
    {
    private static FMLRelauncher INSTANCE;
    public static String logFileNamePattern;
    private static String side;
    private RelaunchClassLoader classLoader;
    private Object newApplet;
    private Class<? super Object> appletClass;

    JDialog popupWindow;

    public static void handleClientRelaunch(ArgsWrapper wrap)
    {
    logFileNamePattern = "ForgeModLoader-client-%g.log";
    side = "CLIENT";
    instance().relaunchClient(wrap);
    }

    public static void handleServerRelaunch(ArgsWrapper wrap)
    {
    logFileNamePattern = "ForgeModLoader-server-%g.log";
    side = "SERVER";
    instance().relaunchServer(wrap);
    }

    static FMLRelauncher instance()
    {
    if (INSTANCE == null)
    {
    INSTANCE = new FMLRelauncher();
    }
    return INSTANCE;

    }

    private FMLRelauncher()
    {
    URLClassLoader ucl = (URLClassLoader) getClass().getClassLoader();

    classLoader = new RelaunchClassLoader(ucl.getURLs());

    }

    private void showWindow(boolean showIt)
    {
    if (RelaunchLibraryManager.downloadMonitor != null) { return; }
    try
    {
    if (showIt)
    {
    RelaunchLibraryManager.downloadMonitor = new Downloader();
    popupWindow = (JDialog) RelaunchLibraryManager.downloadMonitor.makeDialog();
    }
    else
    {
    RelaunchLibraryManager.downloadMonitor = new DummyDownloader();
    }
    }
    catch (Throwable e)
    {
    if (RelaunchLibraryManager.downloadMonitor == null)
    {
    RelaunchLibraryManager.downloadMonitor = new DummyDownloader();
    e.printStackTrace();
    }
    else
    {
    RelaunchLibraryManager.downloadMonitor.makeHeadless();
    }
    popupWindow = null;
    }
    }

    private void relaunchClient(ArgsWrapper wrap)
    {
    showWindow(true);
    // Now we re-inject the home into the "new" minecraft under our control
    Class<? super Object> client;
    try
    {
    File minecraftHome = computeExistingClientHome();
    setupHome(minecraftHome);

    client = setupNewClientHome(minecraftHome);
    }
    finally
    {
    if (popupWindow != null)
    {
    popupWindow.setVisible(false);
    popupWindow.dispose();
    }
    }

    if (RelaunchLibraryManager.downloadMonitor.shouldStopIt())
    {
    System.exit(1);
    }
    try
    {
    ReflectionHelper.findMethod(client, null, new String[] { "fmlReentry" }, ArgsWrapper.class).invoke(null, wrap);
    }
    catch (Exception e)
    {
    e.printStackTrace();
    // Hmmm
    }
    }

    private Class<? super Object> setupNewClientHome(File minecraftHome)
    {
    Class<? super Object> client = ReflectionHelper.getClass(classLoader, "net.minecraft.client.Minecraft");
    ReflectionHelper.setPrivateValue(client, null, minecraftHome, "minecraftDir", "an", "minecraftDir");
    return client;
    }

    private void relaunchServer(ArgsWrapper wrap)
    {
    showWindow(false);
    // Now we re-inject the home into the "new" minecraft under our control
    Class<? super Object> server;
    File minecraftHome = new File(".");
    setupHome(minecraftHome);

    server = ReflectionHelper.getClass(classLoader, "net.minecraft.server.MinecraftServer");
    try
    {
    ReflectionHelper.findMethod(server, null, new String[] { "fmlReentry" }, ArgsWrapper.class).invoke(null, wrap);
    }
    catch (Exception e)
    {
    e.printStackTrace();
    }
    }

    private void setupHome(File minecraftHome)
    {
    FMLInjectionData.build(minecraftHome, classLoader);
    FMLRelaunchLog.minecraftHome = minecraftHome;
    FMLRelaunchLog.info("Forge Mod Loader version %s.%s.%s.%s for Minecraft %s loading", FMLInjectionData.major, FMLInjectionData.minor,
    FMLInjectionData.rev, FMLInjectionData.build, FMLInjectionData.mccversion, FMLInjectionData.mcpversion);

    try
    {
    RelaunchLibraryManager.handleLaunch(minecraftHome, classLoader);
    }
    catch (Throwable t)
    {
    if (popupWindow != null)
    {
    try
    {
    String logFile = new File(minecraftHome, "ForgeModLoader-client-0.log").getCanonicalPath();
    JOptionPane.showMessageDialog(popupWindow, String.format(
    "<html><div align=\"center\"><font size=\"+1\">There was a fatal error starting up minecraft and FML</font></div><br/>"
    + "Minecraft cannot launch in it's current configuration<br/>"
    + "Please consult the file <i><a href=\"file:///%s\">%s</a></i> for further information</html>", logFile, logFile),
    "Fatal FML error", JOptionPane.ERROR_MESSAGE);
    }
    catch (Exception ex)
    {
    // ah well, we tried
    }
    }
    throw new RuntimeException(t);
    }
    }

    /**
    * @return the location of the client home
    */
    private File computeExistingClientHome()
    {
    Class<? super Object> mcMaster = ReflectionHelper.getClass(getClass().getClassLoader(), "net.minecraft.client.Minecraft");
    // If we get the system property we inject into the old MC, setup the
    // dir, then pull the value
    String str = System.getProperty("minecraft.applet.TargetDirectory");
    if (str != null)
    {
    str = str.replace('/', File.separatorChar);
    ReflectionHelper.setPrivateValue(mcMaster, null, new File(str), "minecraftDir", "an", "minecraftDir");
    }
    // We force minecraft to setup it's homedir very early on so we can
    // inject stuff into it
    Method setupHome = ReflectionHelper.findMethod(mcMaster, null, new String[] { "getMinecraftDir", "getMinecraftDir", "b" });
    try
    {
    setupHome.invoke(null);
    }
    catch (Exception e)
    {
    // Hmmm
    }
    File minecraftHome = ReflectionHelper.getPrivateValue(mcMaster, null, "minecraftDir", "an", "minecraftDir");
    return minecraftHome;
    }

    public static void appletEntry(Applet minecraftApplet)
    {
    side = "CLIENT";
    logFileNamePattern = "ForgeModLoader-client-%g.logf";
    instance().relaunchApplet(minecraftApplet);
    }

    private void relaunchApplet(Applet minecraftApplet)
    {
    showWindow(false);

    appletClass = ReflectionHelper.getClass(classLoader, "net.minecraft.client.MinecraftApplet");
    if (minecraftApplet.getClass().getClassLoader() == classLoader)
    {
    if (popupWindow != null)
    {
    popupWindow.setVisible(false);
    popupWindow.dispose();
    }
    try
    {
    newApplet = minecraftApplet;
    ReflectionHelper.findMethod(appletClass, newApplet, new String[] { "fmlInitReentry" }).invoke(newApplet);
    return;
    }
    catch (Exception e)
    {
    System.out.println("FMLRelauncher.relaunchApplet");
    e.printStackTrace();
    throw new RuntimeException(e);
    }
    }

    File mcDir = computeExistingClientHome();
    setupHome(mcDir);
    setupNewClientHome(mcDir);

    Class<? super Object> parentAppletClass = ReflectionHelper.getClass(getClass().getClassLoader(), "java.applet.Applet");

    try
    {
    newApplet = appletClass.newInstance();
    Object appletContainer = ReflectionHelper.getPrivateValue(ReflectionHelper.getClass(getClass().getClassLoader(), "java.awt.Component"),
    minecraftApplet, "parent");

    String launcherClassName = System.getProperty("minecraft.applet.WrapperClass", "net.minecraft.Launcher");
    Class<? super Object> launcherClass = ReflectionHelper.getClass(getClass().getClassLoader(), launcherClassName);
    if (launcherClass.isInstance(appletContainer))
    {
    ReflectionHelper.findMethod(ReflectionHelper.getClass(getClass().getClassLoader(), "java.awt.Container"), minecraftApplet,
    new String[] { "removeAll" }).invoke(appletContainer);
    ReflectionHelper.findMethod(launcherClass, appletContainer, new String[] { "replace" }, parentAppletClass).invoke(appletContainer, newApplet);
    }
    else
    {
    FMLRelaunchLog.severe("Found unknown applet parent %s, unable to inject!\n", appletContainer.getClass().getName());
    throw new RuntimeException();
    }
    }
    catch (Exception e)
    {
    throw new RuntimeException(e);
    }
    finally
    {
    if (popupWindow != null)
    {
    popupWindow.setVisible(false);
    popupWindow.dispose();
    }
    }
    }

    public static void appletStart(Applet applet)
    {
    instance().startApplet(applet);
    }

    private void startApplet(Applet applet)
    {
    if (applet.getClass().getClassLoader() == classLoader)
    {
    if (popupWindow != null)
    {
    popupWindow.setVisible(false);
    popupWindow.dispose();
    }
    if (RelaunchLibraryManager.downloadMonitor.shouldStopIt())
    {
    System.exit(1);
    }
    try
    {
    ReflectionHelper.findMethod(appletClass, newApplet, new String[] { "fmlStartReentry" }).invoke(newApplet);
    }
    catch (Exception e)
    {
    System.out.println("FMLRelauncher.startApplet");
    e.printStackTrace();
    throw new RuntimeException(e);
    }
    }
    return;
    }

    public static String side()
    {
    return side;
    }
    }
    FMLlogformater
    package cpw.mods.fml.relauncher;

    /**
    * Copied from ConsoleLogFormatter for shared use on the client
    *
    */
    import java.io.PrintWriter;
    import java.io.StringWriter;
    import java.text.SimpleDateFormat;
    import java.util.logging.Formatter;
    import java.util.logging.Level;
    import java.util.logging.LogRecord;

    final class FMLLogFormatter extends Formatter
    {
    static final String LINE_SEPARATOR = System.getProperty("line.separator");
    private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    public String format(LogRecord record)
    {
    StringBuilder msg = new StringBuilder();
    msg.append(this.dateFormat.format(Long.valueOf(record.getMillis())));
    Level lvl = record.getLevel();

    String name = lvl.getLocalizedName();
    if ( name == null )
    {
    name = lvl.getName();
    }

    if ( ( name != null ) && ( name.length() > 0 ) )
    {
    msg.append(" [" + name + "] ");
    }
    else
    {
    msg.append(" ");
    }

    if (record.getLoggerName() != null)
    {
    msg.append("["+record.getLoggerName()+"] ");
    }
    else
    {
    msg.append("[] ");
    }
    msg.append(record.getMessage());
    msg.append(LINE_SEPARATOR);
    Throwable thr = record.getThrown();

    if (thr != null)
    {
    StringWriter thrDump = new StringWriter();
    thr.printStackTrace(new PrintWriter(thrDump));
    msg.append(thrDump.toString());
    }

    return msg.toString();
    }
    }
     
  2. Хостинг MineCraft
    <
  3. Автор темы
    МАРАЗМ

    МАРАЗМ Активный участник Пользователь

    Баллы:
    88
    Skype:
    kolyadun3
    Имя в Minecraft:
    Mapa3m1
    FMLrelauncherlog
    package cpw.mods.fml.relauncher;

    import java.io.ByteArrayOutputStream;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileNotFoundException;
    import java.io.IOException;
    import java.io.PrintStream;
    import java.util.concurrent.Executors;
    import java.util.concurrent.LinkedBlockingQueue;
    import java.util.logging.ConsoleHandler;
    import java.util.logging.FileHandler;
    import java.util.logging.Handler;
    import java.util.logging.Level;
    import java.util.logging.LogManager;
    import java.util.logging.LogRecord;
    import java.util.logging.Logger;

    public class FMLRelaunchLog
    {

    private static class ConsoleLogWrapper extends Handler
    {
    @Override
    public void publish(LogRecord record)
    {
    boolean currInt = Thread.interrupted();
    try
    {
    ConsoleLogThread.recordQueue.put(record);
    }
    catch (InterruptedException e)
    {
    e.printStackTrace(errCache);
    }
    if (currInt)
    {
    Thread.currentThread().interrupt();
    }
    }

    @Override
    public void flush()
    {

    }

    @Override
    public void close() throws SecurityException
    {
    }

    }
    private static class ConsoleLogThread implements Runnable
    {
    static ConsoleHandler wrappedHandler = new ConsoleHandler();
    static LinkedBlockingQueue<LogRecord> recordQueue = new LinkedBlockingQueue<LogRecord>();
    @Override
    public void run()
    {
    do
    {
    LogRecord lr;
    try
    {
    lr = recordQueue.take();
    wrappedHandler.publish(lr);
    }
    catch (InterruptedException e)
    {
    e.printStackTrace(errCache);
    Thread.interrupted();
    // Stupid
    }
    }
    while (true);
    }
    }
    private static class LoggingOutStream extends ByteArrayOutputStream
    {
    private Logger log;
    private StringBuilder currentMessage;

    public LoggingOutStream(Logger log)
    {
    this.log = log;
    this.currentMessage = new StringBuilder();
    }

    @Override
    public void flush() throws IOException
    {
    String record;
    synchronized(FMLRelaunchLog.class)
    {
    super.flush();
    record = this.toString();
    super.reset();

    currentMessage.append(record.replace(FMLLogFormatter.LINE_SEPARATOR, "\n"));
    if (currentMessage.lastIndexOf("\n")>=0)
    {
    // Are we longer than just the line separator?
    if (currentMessage.length()>1)
    {
    // Trim the line separator
    currentMessage.setLength(currentMessage.length()-1);
    log.log(Level.INFO, currentMessage.toString());
    }
    currentMessage.setLength(0);
    }
    }
    }
    }
    /**
    * Our special logger for logging issues to. We copy various assets from the
    * Minecraft logger to achieve a similar appearance.
    */
    public static FMLRelaunchLog log = new FMLRelaunchLog();

    static File minecraftHome;
    private static boolean configured;

    private static Thread consoleLogThread;

    private static PrintStream errCache;
    private Logger myLog;

    private static FileHandler fileHandler;

    private static FMLLogFormatter formatter;

    private FMLRelaunchLog()
    {
    }
    /**
    * Configure the FML logger
    */
    private static void configureLogging()
    {
    LogManager.getLogManager().reset();
    Logger globalLogger = Logger.getLogger(Logger.GLOBAL_LOGGER_NAME);
    globalLogger.setLevel(Level.OFF);

    log.myLog = Logger.getLogger("ForgeModLoader");

    Logger stdOut = Logger.getLogger("STDOUT");
    stdOut.setParent(log.myLog);
    Logger stdErr = Logger.getLogger("STDERR");
    stdErr.setParent(log.myLog);
    log.myLog.setLevel(Level.ALL);
    log.myLog.setUseParentHandlers(false);
    consoleLogThread = new Thread(new ConsoleLogThread());
    consoleLogThread.start();
    formatter = new FMLLogFormatter();
    try
    {
    File logPath = new File(minecraftHome, FMLRelauncher.logFileNamePattern);
    fileHandler = new FileHandler(logPath.getPath(), 0, 3)
    {
    public synchronized void close() throws SecurityException {
    // We don't want this handler to reset
    }
    };
    }
    catch (Exception e)
    {
    }

    resetLoggingHandlers();

    // Set system out to a log stream
    errCache = System.err;

    System.setOut(new PrintStream(new LoggingOutStream(stdOut), true));
    System.setErr(new PrintStream(new LoggingOutStream(stdErr), true));

    configured = true;
    }
    private static void resetLoggingHandlers()
    {
    ConsoleLogThread.wrappedHandler.setLevel(Level.parse(System.getProperty("fml.log.level","INFO")));
    // Console handler captures the normal stderr before it gets replaced
    log.myLog.addHandler(new ConsoleLogWrapper());
    ConsoleLogThread.wrappedHandler.setFormatter(formatter);
    fileHandler.setLevel(Level.ALL);
    fileHandler.setFormatter(formatter);
    log.myLog.addHandler(fileHandler);
    }

    public static void loadLogConfiguration(File logConfigFile)
    {
    if (logConfigFile!=null && logConfigFile.exists() && logConfigFile.canRead())
    {
    try
    {
    LogManager.getLogManager().readConfiguration(new FileInputStream(logConfigFile));
    resetLoggingHandlers();
    }
    catch (Exception e)
    {
    log(Level.SEVERE, e, "Error reading logging configuration file %s", logConfigFile.getName());
    }
    }
    }
    public static void log(String logChannel, Level level, String format, Object... data)
    {
    makeLog(logChannel);
    Logger.getLogger(logChannel).log(level, String.format(format, data));
    }

    public static void log(Level level, String format, Object... data)
    {
    if (!configured)
    {
    configureLogging();
    }
    log.myLog.log(level, String.format(format, data));
    }

    public static void log(String logChannel, Level level, Throwable ex, String format, Object... data)
    {
    makeLog(logChannel);
    Logger.getLogger(logChannel).log(level, String.format(format, data), ex);
    }

    public static void log(Level level, Throwable ex, String format, Object... data)
    {
    if (!configured)
    {
    configureLogging();
    }
    log.myLog.log(level, String.format(format, data), ex);
    }

    public static void severe(String format, Object... data)
    {
    log(Level.SEVERE, format, data);
    }

    public static void warning(String format, Object... data)
    {
    log(Level.WARNING, format, data);
    }

    public static void info(String format, Object... data)
    {
    log(Level.INFO, format, data);
    }

    public static void fine(String format, Object... data)
    {
    log(Level.FINE, format, data);
    }

    public static void finer(String format, Object... data)
    {
    log(Level.FINER, format, data);
    }

    public static void finest(String format, Object... data)
    {
    log(Level.FINEST, format, data);
    }
    public Logger getLogger()
    {
    return myLog;
    }
    public static void makeLog(String logChannel)
    {
    Logger l = Logger.getLogger(logChannel);
    l.setParent(log.myLog);
    }
    }
    [DOUBLEPOST=1376654236,1376651047][/DOUBLEPOST]Решено! Суть была в перекрытии показа сессии! ТЫК закинуть в minecraft.jar/net/minecraft/client
    вот что пишет в логе фордж 2013-08-16 14:50:18 [INFO] [STDOUT] Setting user: Mapa3m1, There is not a place for hacker! Go out from log!
    Лайк кому помог)
     
    Likeobot нравится это.

Поделиться этой страницей