gitweb on Svarog

projekti pod git sistemom za održavanje verzija -- projects under the git version control system
TransMessages improvements
authorDoni Pracner <quinnuendo@gmail.com>
Tue, 17 Jul 2018 23:50:47 +0000 (01:50 +0200)
committerDoni Pracner <quinnuendo@gmail.com>
Tue, 17 Jul 2018 23:50:47 +0000 (01:50 +0200)
src/com/quemaster/transformations/TransMessages.java
src/com/quemaster/transformations/mjc2wsl/Mjc2wsl.java

index 042612fe05829f7bb1d04ea7c8d22c257d249944..bd27009bb8d29ec0496facde9b43840d938ab34d 100644 (file)
@@ -1,6 +1,6 @@
 package com.quemaster.transformations;
 /*
-    Copyright (C) 2014  Doni Pracner
+    Copyright (C) 2014, 2018  Doni Pracner
  
     This file is part of mjc2wsl.
 
@@ -29,8 +29,9 @@ public class TransMessages {
        private int[] messageCounters;
        public static final int M_DEB = 0;
        public static final int M_WAR = 1;
-       public static final int M_ERR = 2;
-       public static final int M_QUIET = 3;
+       public static final int M_NOTIFY = 2;
+       public static final int M_ERR = 5;
+       public static final int M_QUIET = 10;
        private PrintStream outStream = System.out;
 
        public TransMessages() {
@@ -45,6 +46,10 @@ public class TransMessages {
                        messageCounters[level]++;
        }
 
+       public void message(String string) {
+               message(string,M_NOTIFY);
+       }
+
        public int getLevelMessageCount(int level){
                if (level < messageCounters.length){
                        return messageCounters[level];
@@ -53,7 +58,11 @@ public class TransMessages {
        }
 
        public void printMessageCounters(PrintStream out){
-                       out.println("total errors:"+messageCounters[TransMessages.M_ERR]+" warnings:"+messageCounters[TransMessages.M_WAR]);
+               if (printLevel < M_QUIET)
+                       out.println("total errors:" + messageCounters[TransMessages.M_ERR] 
+                                       + " warnings:" + messageCounters[TransMessages.M_WAR]
+                                       + " notifications:"     + messageCounters[TransMessages.M_NOTIFY]
+                                                       );
        }
 
        public void printMessageCounters(){
@@ -67,4 +76,5 @@ public class TransMessages {
        public void setPrintLevel(int printLevel) {
                this.printLevel = printLevel;
        }
+
 }
\ No newline at end of file
index 6c3836ee58839aa53d1448c1a8fa1f555cc4dada..d3f72970be9a71651f5ec28e5471a6e979726407 100644 (file)
@@ -374,6 +374,7 @@ public class Mjc2wsl{
 
                int op = mjInput.get();
                while (op >= 0) {
+                       messages.message("Processing "+mjInput.describeOpCode(op)+ " at " + mjInput.getCounter(), TransMessages.M_DEB);
                        prl(" a" + mjInput.getCounter() + " ==");
                        if (originalInComments)
                                prl(createComment(mjInput.describeOpCode(op), C_OC));
@@ -925,6 +926,9 @@ public class Mjc2wsl{
                                        System.err.println("error in opening out file:");
                                        e.printStackTrace();
                                }
+                               if (i + 2 < args.length) {
+                                       messages.message("additional parameters ignored, starting from:'"+args[i+2]+"'", TransMessages.M_ERR);
+                               }
                        }
                        if (out == null) {
                                // if not set to screen, or a file, make a default filename
@@ -944,7 +948,7 @@ public class Mjc2wsl{
                        }
                        long mili = Calendar.getInstance().getTimeInMillis()
                                        - now.getTimeInMillis();
-                       System.out.println("conversion time:" + mili + " ms");
+                       messages.message("conversion time:" + mili + " ms");
                        messages.printMessageCounters();
                        out.close();
                }
Svarog.pmf.uns.ac.rs/gitweb maintanance Doni Pracner