Changeset 433 in tmcsimulator for trunk/webapps/unifiedlogger/logging_service.py


Ignore:
Timestamp:
07/07/2019 11:17:08 AM (7 years ago)
Author:
jdalbey
Message:

Unified Logger v1.0. Add cad watcher plugin to logging service.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/webapps/unifiedlogger/logging_service.py

    r431 r433  
    1 import cms_watcher, time, json 
     1import cms_watcher, cad_watcher, time, json 
    22# Unified Logging Service 
    33# jdalbey 7/6/2019 
     
    1616 
    1717def main(): 
     18    # Delete any previously existing output file 
     19    f = open("../dynamicdata/unifiedlog.html", "w") 
     20    startHTML = "<HTML><HEAD><meta http-equiv=\"refresh\" content=\"5\" /></HEAD><BODY><PRE>" 
     21    f.write(startHTML); 
     22    f.close()             
    1823    # List of the available plugin modules  
    19     plugins = ["cms_watcher"] 
     24    plugins = ["cms_watcher","cad_watcher"] 
    2025    #FOR each plugin LOOP 
    2126    for plugin in plugins: 
    2227        # dynamically load the setup function for this plugin 
    23         plugmodule = locals()[plugin] 
     28        plugmodule = globals()[plugin] 
    2429        setupfunc = getattr(plugmodule, 'setup') 
    2530        #Call setup 
     
    3338    #    Reset Output Buffer 
    3439        output = "" 
     40        results = [] 
    3541    #    FOR each plugin LOOP 
    3642        for plugin in plugins: 
    3743            # dynamically load the setup function for this plugin 
    38             plugmodule = locals()[plugin] 
    39             comparefunc = getattr(plugmodule, 'compare') 
     44            plugmodule = globals()[plugin] 
     45            getfunc = getattr(plugmodule, 'getLogEntries') 
    4046             
    4147    #        Run the plugin process returning new log entries 
    42             results = comparefunc()          # Look for changed messages 
     48            results = getfunc()      
     49            #    Append simulation time and the log entries to the Output Buffer 
     50            for item in results: 
     51                trimmed_item = item.strip() 
     52                if len(trimmed_item) > 0: 
     53                    output += timeStamp + " " + trimmed_item + "\n" 
    4354    #    END LOOP 
    44     #    Append simulation time and the log entries to the Output Buffer 
    45         for item in results: 
    46             output += timeStamp + " " + item + "\n" 
    4755    #    IF the Output Buffer has any contents THEN 
    4856        if len(output) > 0: 
    4957    #       Write (append) Output Buffer to unified log file  
    50             print output 
     58            print output, 
     59            f = open("../dynamicdata/unifiedlog.html", "a") 
     60            f.write(output) 
     61            f.close()             
    5162    #    END IF 
    5263    #    Wait one second 
Note: See TracChangeset for help on using the changeset viewer.