Changeset 9:8ad424212eed in rrlib_logging-java


Ignore:
Timestamp:
14.07.2019 14:13:34 (2 months ago)
Author:
Max Reichardt <mreichardt@…>
Branch:
17.03
Phase:
public
Message:

Aligns log domain configuration from log config files with C++ version of rrlib_logging (-> log config files used for C++ applications can now also be used in Java)

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • LogDomain.java

    r8 r9  
    118118     */ 
    119119    void configureSubTree() { 
    120         if (parent != null && parent.configuration.configureSubTree) { 
     120        if (parent != null) { 
    121121            configuration = new LogDomainConfiguration(configuration.name, parent.configuration); 
    122122            for (LogDomain ld : children) { 
     
    177177                } else if (ls == LogStreamOutput.COMBINED_FILE) { 
    178178                    LogDomain domain = this; 
    179                     for (; domain.parent != null && domain.parent.configuration.configureSubTree; domain = domain.parent) {} 
     179                    for (; domain.parent != null; domain = domain.parent) {} 
    180180                    tmp.add(domain.openFileOutputStream() ? fileStream : System.err); 
    181181                } 
  • LogDomainConfiguration.java

    r0 r9  
    5050 
    5151    String name; 
    52     boolean configureSubTree; 
    5352 
    5453    boolean enabled = true; 
     
    6968    LogDomainConfiguration(String name, LogDomainConfiguration other) { 
    7069        this.name = name; 
    71         configureSubTree = other.configureSubTree; 
    7270        enabled = other.enabled; 
    7371        printTime = other.printTime; 
  • LogDomainRegistry.java

    r2 r9  
    154154        assert(node.getNodeName().equals("domain")); 
    155155 
    156         String prefix = (parentName == "." ? "" : parentName) + "."; 
     156        String prefix = (parentName.equals(".") ? "" : parentName) + "."; 
    157157        String nodeName = node.getAttributes().getNamedItem("name").getNodeValue().trim(); 
    158         String name = prefix + (parentName.length() == 0 && nodeName == "global" ? "" : nodeName); 
    159  
    160         Node item = node.getAttributes().getNamedItem("configures_sub_tree"); 
    161         if (item != null) { 
    162             setDomainConfiguresSubTree(name, item.getNodeValue().trim().toLowerCase().equals("true")); 
    163         } 
    164  
    165         item = node.getAttributes().getNamedItem("enabled"); 
     158        if (nodeName.equals(".")) { 
     159            nodeName = ""; 
     160        } 
     161        String name = prefix + (parentName.length() == 0 && nodeName.equals("global") ? "" : nodeName); 
     162 
     163        Node item = node.getAttributes().getNamedItem("enabled"); 
    166164        if (item != null) { 
    167165            setDomainIsEnabled(name, item.getNodeValue().trim().toLowerCase().equals("true")); 
    168166        } 
    169167 
    170         item = node.getAttributes().getNamedItem("print_time"); 
     168        item = node.getAttributes().getNamedItem("prints_time"); 
    171169        if (item != null) { 
    172170            setDomainPrintsTime(name, item.getNodeValue().trim().toLowerCase().equals("true")); 
    173171        } 
    174172 
    175         item = node.getAttributes().getNamedItem("print_name"); 
     173        item = node.getAttributes().getNamedItem("prints_name"); 
    176174        if (item != null) { 
    177175            setDomainPrintsName(name, item.getNodeValue().trim().toLowerCase().equals("true")); 
    178176        } 
    179177 
    180         item = node.getAttributes().getNamedItem("print_level"); 
     178        item = node.getAttributes().getNamedItem("prints_level"); 
    181179        if (item != null) { 
    182180            setDomainPrintsLevel(name, item.getNodeValue().trim().toLowerCase().equals("true")); 
    183181        } 
    184182 
    185         item = node.getAttributes().getNamedItem("print_location"); 
     183        item = node.getAttributes().getNamedItem("prints_location"); 
    186184        if (item != null) { 
    187185            setDomainPrintsLocation(name, item.getNodeValue().trim().toLowerCase().equals("true")); 
     
    302300    } 
    303301 
    304 // TODO: maybe.. 
    305 // /** Get the length of the longest full qualified domain name 
    306 //  * 
    307 //  * This method can be used for formatting user dialogs 
    308 //  * 
    309 //  * @return The length of the longest domain name 
    310 //  */ 
    311 // public int GetMaxDomainNameLength() { 
    312 // 
    313 // } 
    314  
    315     /** Enable a given domain and switch recursion on or off 
    316     * 
    317     * This is a shortcut for setting the configuration of the domain's 
    318     * sub tree and enabling it. 
    319     * 
    320     * @param name            The full qualified name of the domain 
    321     */ 
    322     public void enableDomain(String name) { 
    323         enableDomain(name, false); 
    324     } 
    325  
    326     /** Enable a given domain and switch recursion on or off 
    327      * 
    328      * This is a shortcut for setting the configuration of the domain's 
    329      * sub tree and enabling it. 
    330      * 
    331      * @param name            The full qualified name of the domain 
    332      * @param withSubTree   Switch recursion on or off 
    333      */ 
    334     public void enableDomain(String name, boolean withSubTree) { 
    335         setDomainConfiguresSubTree(name, withSubTree); 
    336         setDomainIsEnabled(name, true); 
    337     } 
    338  
    339     /** Disable a given domain and switch recursion on or off 
    340     * 
    341     * This is a shortcut for setting the configuration of the domain's 
    342     * sub tree and disabling it. 
    343     * 
    344     * @param name            The full qualified name of the domain 
    345     */ 
    346     public void disableDomain(String name) { 
    347         disableDomain(name, false); 
    348     } 
    349  
    350     /** Disable a given domain and switch recursion on or off 
    351      * 
    352      * This is a shortcut for setting the configuration of the domain's 
    353      * sub tree and disabling it. 
    354      * 
    355      * @param name            The full qualified name of the domain 
    356      * @param withSubTree   Switch recursion on or off 
    357      */ 
    358     public void disableDomain(String name, boolean withSubTree) { 
    359         setDomainConfiguresSubTree(name, withSubTree); 
    360         setDomainIsEnabled(name, false); 
    361     } 
    362  
    363     /** Set if the domain configures its subtree or not 
    364      * 
    365      * If set to true every configuration update to the given domain 
    366      * will be propagated to its subtree. 
    367      * 
    368      * @param name    The full qualified name of the domain 
    369      * @param value   The new value of the setting 
    370      */ 
    371     public void setDomainConfiguresSubTree(String name, boolean value) { 
    372         LogDomainConfiguration configuration = getConfigurationByName(name); 
    373         configuration.configureSubTree = value; 
    374         propagateDomainConfigurationToChildren(name); 
    375     } 
    376  
    377302    /** Set if the domain is enabled or not 
    378303     * 
     
    493418            Document doc = dbuilder.parse(fileName); 
    494419 
    495             return configureFromXMLNode(doc.getFirstChild()); 
     420            return configureFromXMLNode(doc.getDocumentElement()); 
    496421        } catch (Exception e) { 
    497422            System.err.println("RRLib Logging: tLoggingDomainRegistry::ConfigureFromFile >> " + e.getMessage()); 
     
    512437     */ 
    513438    public boolean configureFromXMLNode(Node node) { 
    514         if (node.getNodeName() != "rrlib_logging") { 
     439        if (!node.getNodeName().equals("rrlib_logging")) { 
    515440            System.err.println("RRLib Logging: tLoggingDomainRegistry::ConfigureFromXMLNode >> Unexpected content (Not an rrlib_logging tree)"); 
    516441            return false; 
Note: See TracChangeset for help on using the changeset viewer.