HeyImJamie Posted September 5, 2017 Share Posted September 5, 2017 (edited) Probably being retarded here but I've been testing accessing a MySQL database and using System.out to check for errors - got it to work fine but since moving it over to osbot I've been trying to use the logger but can't access it Is there a way to use it outside onLoop etc or is there a way I've completely missed to use System.out.println? Edited September 5, 2017 by HeyImJamie Quote Link to comment Share on other sites More sharing options...
Butters Posted September 5, 2017 Share Posted September 5, 2017 Use log() instead of System.out. Quote Link to comment Share on other sites More sharing options...
HeyImJamie Posted September 5, 2017 Author Share Posted September 5, 2017 1 minute ago, nosepicker said: Use log() instead of System.out. That's what I'm struggling with. My voids are static and I can't access log Quote Link to comment Share on other sites More sharing options...
Butters Posted September 5, 2017 Share Posted September 5, 2017 Pass in your main class to the method as a prameter where you want to use System.out then. Then do ParamName.log(); Quote Link to comment Share on other sites More sharing options...
Final Posted September 5, 2017 Share Posted September 5, 2017 (edited) Lord help your soul, son. Might as well help and not shit post: Pass in the reference of the logger wherever you'd like and use it. Edited September 5, 2017 by Final 1 Quote Link to comment Share on other sites More sharing options...
Explv Posted September 5, 2017 Share Posted September 5, 2017 9 minutes ago, HeyImJamie said: That's what I'm struggling with. My voids are static and I can't access log 5 minutes ago, nosepicker said: Pass in your main class to the method as a prameter where you want to use System.out then. Then do ParamName.log(); That or run OSBot in debug mode with the -debug flag, you can then see your printlns in CMD (or terminal) 3 Quote Link to comment Share on other sites More sharing options...
Juggles Posted September 5, 2017 Share Posted September 5, 2017 Pass log from main class Quote Link to comment Share on other sites More sharing options...
Team Cape Posted September 5, 2017 Share Posted September 5, 2017 (edited) 38 minutes ago, HeyImJamie said: Probably being retarded here but I've been testing accessing a MySQL database and using System.out to check for errors - got it to work fine but since moving it over to osbot I've been trying to use the logger but can't access it Is there a way to use it outside onLoop etc or is there a way I've completely missed to use System.out.println? public class Logger { private static MethodProvider m; private Logger() { } public static void setup(MethodProvider m) { Logger.m = m; } public static void log(String message) { if(m != null) m.log(message); } } this is a pretty basic way of doing it. just call setup in your onStart() and you should be able to use this. if you want a staticly accessible version of m just create a getter for m Edited September 5, 2017 by Team Cape Quote Link to comment Share on other sites More sharing options...
HeyImJamie Posted September 5, 2017 Author Share Posted September 5, 2017 Ty all. Quote Link to comment Share on other sites More sharing options...
dreameo Posted September 5, 2017 Share Posted September 5, 2017 (edited) 29 minutes ago, Team Cape said: public class Logger { private static MethodProvider m; private Logger() { } public static void setup(MethodProvider m) { Logger.m = m; } public static void log(String message) { if(m != null) m.log(message); } } this is a pretty basic way of doing it. just call setup in your onStart() and you should be able to use this. if you want a staticly accessible version of m just create a getter for m Logger logger = new Logger(); logger.m = m; edit: im thinkin more singleton but urs is fine ;) Edited September 5, 2017 by dreameo Quote Link to comment Share on other sites More sharing options...
Team Cape Posted September 5, 2017 Share Posted September 5, 2017 Just now, dreameo said: Logger logger = new Logger(); logger.m = m; he wanted it to be static Quote Link to comment Share on other sites More sharing options...
dreameo Posted September 5, 2017 Share Posted September 5, 2017 18 minutes ago, Team Cape said: he wanted it to be static yea bbg, I meant Logger logger; private Logger() {} Private Mp mp; public initLog(Mp mp) { if(logger == null) logger = new Logger() logger.mp = mp; } . . . Singleton op (somfin like dat) Quote Link to comment Share on other sites More sharing options...
HeyImJamie Posted September 5, 2017 Author Share Posted September 5, 2017 Using -debug works ok for now. While you're here, does OSbot even allow for external libs? Using the jbdc mysql driver and it's throwing classnotfound even though it's working on my tester -.- Quote Link to comment Share on other sites More sharing options...
Chris Posted September 5, 2017 Share Posted September 5, 2017 42 minutes ago, HeyImJamie said: Using -debug works ok for now. While you're here, does OSbot even allow for external libs? Using the jbdc mysql driver and it's throwing classnotfound even though it's working on my tester -.- no u need to add the library to ur project Quote Link to comment Share on other sites More sharing options...
HeyImJamie Posted September 5, 2017 Author Share Posted September 5, 2017 8 minutes ago, Chris said: no u need to add the library to ur project I did but apparently security settings block access -.- Quote Link to comment Share on other sites More sharing options...