last day (15 days later) » 

16:05
Hey Adrian!
I'm Jayvin, a former MVP out of Philadelphia
thanks for offering your help!
I used your logger logic. I have a class with a static method. It works great in my packaging org, but the location logic doesn't work in the subscriber org
16:24
Location logic?
getting the class, method, line, and column
So you're just talking about the regex?
i think so, yes
i think the issue might be before the regex, actually.
private static void addLog(Exception ex, LoggingLevel level, String message, Object value) {
if (!(isLogsOn && logLevels.get(controlLevel).contains(level))) {
return;
}
String className = '';
String methodName = '';
String line = '';
String column = '';
String location = '';
String msg = '';
String valueW = '';
String locationErr = '';

try {
//get the location
locationErr = 'stacktrace for location=' + ex.getStackTraceString(); //this returns the name space in parenthesis which i think is wrong
I think that's just how the Exception.getStackTracString method works in managed code. It's to protect you.
ok... here is the rest of that code block, it's not giving me the location info. Any ideas?
Matcher m = thePattern.matcher(ex.getStackTraceString().split('\n', 3)[1]);

if (m.find()) {
String[] groups = new List<String>{
m.group(1),
m.group(2),
m.group(3),
m.group(4),
m.group(5)
};
if (String.isBlank(groups[2])) {
className = groups[0];
methodName = groups[1];
} else {
className = groups[0] + '.' + groups[1];
methodName = groups[2];
}
line = groups[3];
column = groups[4];
}

location = '{className}.{methodName}:{line},{column}'
.replace('{className}', className)
.replace('{methodName}', methodName)
16:31
I think the core premise is flawed. If you can't get the stack trace because you're in managed code, none of the code will work.
I could be wrong though. Might depend on how you generate the logs.
that's where i was going with my initial question.... in your implementation you use a member variable logger - rather than a static approach like i'm doing here.... i wondered if that had anything to do with this issue
17:14
Member vs static is completely irrelevant. Core concern is if you can successfully retrieve stack trace.
 
2 hours later…
19:40
So i'm trying it a few different ways, and i don't think we can get the stack trace

last day (15 days later) »