Exemple #1
0
  public static void main(String args[]) {
    ConsoleHandler ch = new ConsoleHandler();
    ch.setLevel(Level.FINEST);

    JavaLN l = new JavaLN();
    l.setLevel(Level.FINEST);
    l.addHandler(ch);
    l.setUseParentHandlers(false);

    l.info(l.toString());
    l.severe("this is a test");
    l.entering("not", "needed"); // check for call to base class
    l.entering();
    l.entering(new Integer(10));
    l.entering(args);
    l.entering(new Object[] {new Integer(1), "one"});
    l.exiting();
    l.exiting("exiting");
    l.throwing(new Throwable("Throwable message"));

    JavaLN m = new JavaLN("one");
    m.severe(m.toString());
    m.severe("this is another test");

    JavaLN n = new JavaLN("two", null);
    n.severe(n.toString());
    n.severe("this is a third test");
    n.warning(new Throwable("this is a test"));
  }
Exemple #2
0
  REplican(String arguments[]) {
    JCLO jclo = new JCLO(args);

    if (arguments.length == 0) {
      System.out.println("Arguments:\n" + jclo.usage() + "URLs...");
      System.exit(1);
    }

    try {
      jclo.parse(arguments);
    } catch (IllegalArgumentException IAE) {
      System.err.println(IAE);
      System.err.println("Arguments:\n" + jclo.usage() + "URLs...");
      System.exit(0);
    }

    String logLevel = args.LogLevel;
    ConsoleHandler ch = new ConsoleHandler();

    if (logLevel != null) {
      Level level = JavaLN.getLevel(logLevel);
      ch.setLevel(level);
      ch.setFormatter(new LineNumberFormatter());
      logger.setLevel(level);
    } else {
      ch.setFormatter(new NullFormatter());
    }

    logger.addHandler(ch);
    logger.setUseParentHandlers(false);

    if (args.Version) {
      System.out.println(Version.getVersion());
      System.exit(0);
    }

    if (args.Help) {
      System.out.println("Arguments:\n" + jclo.usage() + "URLs...");
      System.exit(0);
    }

    cookies = new Cookies();

    setDefaults();

    if (args.LoadCookies != null) {
      for (int i = 0; i < args.LoadCookies.length; i++) {
        logger.config("Loading cookies from " + args.LoadCookies[i]);
        cookies.loadCookies(args.LoadCookies[i]);
      }
    }

    if (args.PlistCookies != null) {
      for (int i = 0; i < args.PlistCookies.length; i++) {
        logger.config("Loading cookies from " + args.PlistCookies[i]);
        new Plist("file:" + args.PlistCookies[i], cookies);
      }
    }

    if (args.CheckpointEvery != 0) {
      logger.config("Loading urls from " + args.CheckpointFile);

      try {
        ObjectInputStream ois = new ObjectInputStream(new FileInputStream(args.CheckpointFile));
        urls = (Hashtable) ois.readObject();
        ois.close();
      } catch (IOException ioe) {
        logger.throwing(ioe);
      } catch (ClassNotFoundException cnfe) {
        logger.throwing(cnfe);
      }
    }

    if (args.FollowRedirects) HttpURLConnection.setFollowRedirects(false);
  }