def setup_things(options, arguments): # We need to do this after we have read the configuration files. # debug switches for ocaml if getattr(options, 'debugpillsizereports'): ocamlfeatures.set('debug', 'do_ocaml_pill_memory_reports', 'true') else: ocamlfeatures.set('debug', 'do_ocaml_pill_memory_reports', 'false') #if getattr(options, 'slavelog'): # ocamlfeatures.set('nmag','slavelog','true') #else: # ocamlfeatures.set('nmag','slavelog','false') log.debug("Ocamlfeatures after dealing with command line arguments:\n%s" % str(ocamlfeatures)) # Do we actually need this? # fangohr 26/08/2008: Yes, this is useful for debugging and to understand # the configuration code. # Write current configurations if required if pyfeatures.get('nmag', 'dumpconf', raw=True): log.info("Found --dumpconf switch, dumping configurations...") runidbase = os.path.join(pyfeatures.get('etc', 'savedir'), pyfeatures.get('etc', 'runid')) conf_filename_1 = runidbase + '_nmag.conf' pyfeatures.to_file(conf_filename_1) log.info("Found --dumpconf switch: pyfeatures -> '%s'" % conf_filename_1) conf_filename_2 = runidbase + '_ocaml.conf' open(conf_filename_2, 'w').write(str(ocamlfeatures)) log.info("Found --dumpconf switch: ocamlfeatures -> '%s'" % conf_filename_2) logfilepath = pyfeatures.config.defaults()['logfilepath'] logconf = nsim.features.Features(local=True, defaults={'logfilepath': logfilepath}) logconfigfilename = pyfeatures.get('nmag', 'logconfigfile') logconf.from_file(logconfigfilename) conf_filename_3 = runidbase + '_log.conf' logconf.to_file(conf_filename_3) log.info("Found --dumpconf switch: logging.conf -> '%s'" % conf_filename_3) if pyfeatures.get('nmag', 'slavelog', raw=True): import ocaml ocaml.nlog_log_mpi('ocaml.ocaml', 20, 'Log messages from slaves are reported to stdout')
def setup_things(options, arguments): # We need to do this after we have read the configuration files. # debug switches for ocaml if getattr(options, 'debugpillsizereports'): ocamlfeatures.set('debug', 'do_ocaml_pill_memory_reports', 'true') else: ocamlfeatures.set('debug', 'do_ocaml_pill_memory_reports', 'false') #if getattr(options, 'slavelog'): # ocamlfeatures.set('nmag','slavelog','true') #else: # ocamlfeatures.set('nmag','slavelog','false') log.debug("Ocamlfeatures after dealing with command line arguments:\n%s" % str(ocamlfeatures)) # Do we actually need this? # fangohr 26/08/2008: Yes, this is useful for debugging and to understand # the configuration code. # Write current configurations if required if pyfeatures.get('nmag', 'dumpconf', raw=True): log.info("Found --dumpconf switch, dumping configurations...") runidbase = os.path.join(pyfeatures.get('etc', 'savedir'), pyfeatures.get('etc', 'runid')) conf_filename_1 = runidbase + '_nmag.conf' pyfeatures.to_file(conf_filename_1) log.info("Found --dumpconf switch: pyfeatures -> '%s'" % conf_filename_1) conf_filename_2 = runidbase + '_ocaml.conf' open(conf_filename_2, 'w').write(str(ocamlfeatures)) log.info("Found --dumpconf switch: ocamlfeatures -> '%s'" % conf_filename_2) logfilepath = pyfeatures.config.defaults()['logfilepath'] logconf = nsim.features.Features(local=True, defaults={'logfilepath':logfilepath}) logconfigfilename = pyfeatures.get('nmag', 'logconfigfile') logconf.from_file(logconfigfilename) conf_filename_3 = runidbase + '_log.conf' logconf.to_file(conf_filename_3) log.info("Found --dumpconf switch: logging.conf -> '%s'" % conf_filename_3) if pyfeatures.get('nmag', 'slavelog', raw=True): import ocaml ocaml.nlog_log_mpi('ocaml.ocaml', 20, 'Log messages from slaves are reported to stdout')
import nmag import ocaml ocaml.nlog_setupLogger('test') def mypythonhandler(level,msg): print "mypythonhandler: %d '%s'" % (level,msg) #nmag.setup.pyfeatures.to_ocaml_features() #print "YYYYYYYYY About to call ergister handler" #print "YYYYYYYYY get_feature:",ocaml.snippets_get_feature('nmag','slavelog') ocaml.nlog_register_handler('test',mypythonhandler) #print "ZZZ get_feature:",ocaml.snippets_get_feature('nmag','slavelog') #print message on all nodes ocaml.nlog_log_mpi('test',51,'High priority Test message from all nodes') print "Setting loglevel to 20" ocaml.nlog_setLogLevel('test',20) ocaml.nlog_log_mpi('test',10,'Debug Test message from all nodes (should not be shown)') print "Setting loglevel to 10" ocaml.nlog_setLogLevel('test',10) ocaml.nlog_log_mpi('test',10,'Debug Test2 message from all nodes') nmag.ipython()