Package de.mhus.lib.logging

Examples of de.mhus.lib.logging.ConsoleFactory


  @Override
  public synchronized IConfig getConfig() {
    if (config == null ) {
         
      Log l = new ConsoleFactory("init",System.out);
      l.setTrace(true);
     
      if (defaultConfigFile != null) {
        l.t("Load Config","default config file",defaultConfigFile);
        File f = new File(defaultConfigFile);
        try {
          if (f.exists()) {
            config = MConfigFactory.getInstance().createConfigFor(f);
          } else {
            l.t("Load Config","default config file not exists");
          }
        } catch (Exception e) {
          l.t("Load Config",e);
        }
      }
     
      getArguments();
      if (args != null) {
        String path = args.getValue("m_config_file", 0);
        if (path != null) {
          l.t("Load Config","config from args",path);
          try {
            File f = new File(path);
            if (f.exists()) {
              config = MConfigFactory.getInstance().createConfigFor(f);
            } else {
              l.t("Load Config","config from args not exists");
            }
          } catch (Exception e) {
            l.t("Load Config",e);
          }
        }
        String[] a = args.getValues("m_config_arg");
        for (String a1 : a) {
          String k = MString.beforeIndex(a1, '=');
          String v = MString.afterIndex(a1, '=');
          try {
            l.t("Load Config","Overwrite key from args",k,v);
            config.setString(k, v);
          } catch (MException e) {}
        }
      } else
      if (System.getProperty("m_config_file") != null) {
        String path = System.getProperty("m_config_file");
        if (path != null) {
          l.t("Load Config","config from env",path);
          try {
            File f = new File(path);
            if (f.exists()) {
              config = MConfigFactory.getInstance().createConfigFor(f);
            } else {
              l.t("Load Config","config from env not exists");
            }
          } catch (Exception e) {
            l.t("Load Config",e);
          }
        }       
      }
     
      if (config == null) {
        l.t("Load Config","Empty Config");
        config = new HashConfig();
      }
    }

    return config;
View Full Code Here

TOP

Related Classes of de.mhus.lib.logging.ConsoleFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.