Skip to content

Commit fd4e42f

Browse files
committed
System Touch
1 parent d125daa commit fd4e42f

1 file changed

Lines changed: 67 additions & 6 deletions

File tree

source/commons/CommonRails.java

Lines changed: 67 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,67 @@ public CommonRails()
6767
}
6868

6969
// Color constants
70-
private static final String ANSI_WHITE = "\033[38;5;15m";
71-
private static final String ANSI_DEEP_RED = "\033[38;5;160m";
72-
private static final String ANSI_SILVER = "\033[38;5;250m";
73-
private static final String ANSI_IMPERIAL_GRAY = "\u001B[38;5;242m";
74-
private static final String ANSI_RESET = "\u001B[0m";
70+
private static final String ANSI_WHITE = "\033[38;5;15m";
71+
private static final String ANSI_DEEP_RED = "\033[38;5;160m";
72+
private static final String ANSI_SILVER = "\033[38;5;250m";
73+
private static final String ANSI_IMPERIAL_GRAY= "\u001B[38;5;242m";
74+
private static final String ANSI_RESET = "\u001B[0m";
75+
76+
// Object-ID category colors (applied to the numeric digits only)
77+
private static final String OID_SECURITY = "\033[38;5;196m"; // bright red
78+
private static final String OID_TELNET = "\033[38;5;51m"; // cyan
79+
private static final String OID_ENCRYPTION = "\033[38;5;208m"; // orange
80+
private static final String OID_BITCOIN = "\033[38;5;220m"; // gold
81+
private static final String OID_LOGGING = "\033[38;5;147m"; // lavender
82+
private static final String OID_MESSAGING = "\033[38;5;118m"; // lime green
83+
private static final String OID_CONNECTIONS = "\033[38;5;75m"; // sky blue
84+
private static final String OID_SERVER = "\033[38;5;214m"; // amber
85+
private static final String OID_LIVENESS = "\033[38;5;46m"; // bright green
86+
private static final String OID_DEFAULT = "\033[38;5;250m"; // silver
87+
88+
/**
89+
* Resolve which Object-ID color to use based on the owner's simple class name.
90+
*/
91+
private static String resolveOidColor(String simpleClassName)
92+
{
93+
if (simpleClassName == null) return OID_DEFAULT;
94+
95+
String low = simpleClassName.toLowerCase();
96+
97+
if (low.contains("security") || low.contains("port") || low.contains("auth"))
98+
return OID_SECURITY;
99+
100+
if (low.contains("telnet") || low.contains("proxy") || low.contains("communicator"))
101+
return OID_TELNET;
102+
103+
if (low.contains("encrypt") || low.contains("aes") || low.contains("cipher"))
104+
return OID_ENCRYPTION;
105+
106+
if (low.contains("bitcoin") || low.contains("trader") || low.contains("wallet"))
107+
return OID_BITCOIN;
108+
109+
if (low.contains("common") || low.contains("rail") || low.contains("logger")
110+
|| low.contains("national") || low.contains("driver") || low.contains("iranian")
111+
|| low.contains("wedding"))
112+
return OID_LOGGING;
113+
114+
if (low.contains("message") || low.contains("queue") || low.contains("sorter")
115+
|| low.contains("handler") || low.contains("orderer"))
116+
return OID_MESSAGING;
117+
118+
if (low.contains("connection") || low.contains("poller") || low.contains("socket")
119+
|| low.contains("galactic") || low.contains("international") || low.contains("recorded"))
120+
return OID_CONNECTIONS;
121+
122+
if (low.contains("server") || low.contains("express") || low.contains("nitro")
123+
|| low.contains("base") || low.contains("installer"))
124+
return OID_SERVER;
125+
126+
if (low.contains("liveness") || low.contains("monitor"))
127+
return OID_LIVENESS;
128+
129+
return OID_DEFAULT;
130+
}
75131

76132
public static <T> Integer size(ArrayList<T> list)
77133
{
@@ -143,7 +199,12 @@ public static void printSystemComponent(Object object, Integer hashcode, String
143199

144200
String compliant_hashcode = String.format("%010d", hashcode);
145201

146-
String object_id = "-- : [Object ID: "+compliant_hashcode+"]";
202+
// Color the numeric digits by object category when color output is enabled
203+
String colored_hashcode = USE_COLORED_OUTPUT
204+
? resolveOidColor(object.getClass().getSimpleName()) + compliant_hashcode + ANSI_RESET
205+
: compliant_hashcode;
206+
207+
String object_id = "-- : [Object ID: "+colored_hashcode+"]";
147208

148209
// Use full date/time in EST for the Date field
149210
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");

0 commit comments

Comments
 (0)