Botre Posted March 4, 2016 Share Posted March 4, 2016 (edited) (Short introduction to yet another tool, blablabla.) No more commenting out debug logs, no more explicit conditional logging, no more spamming your users with debug logs they have no use for. Log to the osbot console, a file or any other log processor you can think of. Log processors automatically filter out log objects that do not meet the processor's levlel requirement. Each log processor can have its own requirements, you might not want to spam the user with debug or trace messages in the console, but storing those messages in a file (where they don't harass the user) could be a valuable practice. Code example: @ScriptManifest(author = "Botre", info = "", logo = "", name = "Simplog Example", version = 0) public class ExampleScript extends Script { private Logger logger; public static final int LOG_USER = 100; public static final int LOG_DEV_DEBUG = 10; public static final int LOG_DEV_TRACE = 1; @Override public void onStart() throws InterruptedException { super.onStart(); /* * Set-up */ logger = new Logger(); logger.addProcessor(new OSBotLogProcessor(this, LOG_USER)); logger.addProcessor(new TextFileLogProcessor(new File("C:/Users/bjorn/Desktop/TextTest.txt"), LOG_DEV_TRACE)); logger.start(); logger.log("Welcome user", LOG_USER); logger.log("Exit onStart", LOG_DEV_TRACE); } @SuppressWarnings("unchecked") @Override public int onLoop() throws InterruptedException { logger.log("Enter onLoop", LOG_DEV_TRACE); logger.log("Started npc filtering", LOG_DEV_TRACE); List<NPC> goblins = getNpcs().filter(npc -> npc.exists() && npc.getName().equals("Goblin")); logger.log("Finished npc filtering", LOG_DEV_TRACE); logger.log("Goblins found: " + goblins.size(), LOG_DEV_DEBUG); logger.log("Exit onLoop", LOG_DEV_TRACE); return 500; } @Override public void onExit() throws InterruptedException { super.onExit(); logger.log("Bye user", LOG_USER); logger.log("Exit onExit", LOG_DEV_TRACE); logger.stop(); } } OSBot log: [INFO][Bot #1][03/04 05:54:17 PM]: Started script : Simplog Example [INFO][Bot #1][03/04 05:54:28 PM]: Welcome user [INFO][Bot #1][03/04 05:54:27 PM]: Terminating script Simplog Example... [INFO][Bot #1][03/04 05:54:27 PM]: Bye user [INFO][Bot #1][03/04 05:54:27 PM]: Script Simplog Example has exited! File log: [2016-03-04T16:54:17Z] LOG SESSION STARTED [2016-03-04T16:54:17Z] Welcome user [2016-03-04T16:54:17Z] Exit onStart [2016-03-04T16:54:17Z] Enter onLoop [2016-03-04T16:54:17Z] Started npc filtering [2016-03-04T16:54:17Z] Finished npc filtering [2016-03-04T16:54:17Z] Goblins found: 3 [2016-03-04T16:54:17Z] Exit onLoop [2016-03-04T16:54:17Z] Enter onLoop [2016-03-04T16:54:17Z] Started npc filtering [2016-03-04T16:54:17Z] Finished npc filtering [2016-03-04T16:54:17Z] Goblins found: 4 [2016-03-04T16:54:17Z] Exit onLoop [2016-03-04T16:54:18Z] Enter onLoop [2016-03-04T16:54:18Z] Started npc filtering [2016-03-04T16:54:18Z] Finished npc filtering [2016-03-04T16:54:18Z] Goblins found: 4 [2016-03-04T16:54:18Z] Exit onLoop [2016-03-04T16:54:18Z] Enter onLoop [2016-03-04T16:54:18Z] Started npc filtering [2016-03-04T16:54:18Z] Finished npc filtering [2016-03-04T16:54:18Z] Goblins found: 4 [2016-03-04T16:54:18Z] Exit onLoop [2016-03-04T16:54:19Z] Enter onLoop [2016-03-04T16:54:19Z] Started npc filtering [2016-03-04T16:54:19Z] Finished npc filtering [2016-03-04T16:54:19Z] Goblins found: 4 [2016-03-04T16:54:19Z] Exit onLoop [2016-03-04T16:54:19Z] Enter onLoop [2016-03-04T16:54:19Z] Started npc filtering [2016-03-04T16:54:19Z] Finished npc filtering [2016-03-04T16:54:19Z] Goblins found: 4 [2016-03-04T16:54:19Z] Exit onLoop [2016-03-04T16:54:20Z] Enter onLoop [2016-03-04T16:54:20Z] Started npc filtering [2016-03-04T16:54:20Z] Finished npc filtering [2016-03-04T16:54:20Z] Goblins found: 4 [2016-03-04T16:54:20Z] Exit onLoop [2016-03-04T16:54:20Z] Enter onLoop [2016-03-04T16:54:20Z] Started npc filtering [2016-03-04T16:54:20Z] Finished npc filtering [2016-03-04T16:54:20Z] Goblins found: 4 [2016-03-04T16:54:20Z] Exit onLoop [2016-03-04T16:54:21Z] Enter onLoop [2016-03-04T16:54:21Z] Started npc filtering [2016-03-04T16:54:21Z] Finished npc filtering [2016-03-04T16:54:21Z] Goblins found: 4 [2016-03-04T16:54:21Z] Exit onLoop [2016-03-04T16:54:21Z] Enter onLoop [2016-03-04T16:54:21Z] Started npc filtering [2016-03-04T16:54:21Z] Finished npc filtering [2016-03-04T16:54:21Z] Goblins found: 4 [2016-03-04T16:54:21Z] Exit onLoop [2016-03-04T16:54:22Z] Enter onLoop [2016-03-04T16:54:22Z] Started npc filtering [2016-03-04T16:54:22Z] Finished npc filtering [2016-03-04T16:54:22Z] Goblins found: 4 [2016-03-04T16:54:22Z] Exit onLoop [2016-03-04T16:54:22Z] Enter onLoop [2016-03-04T16:54:22Z] Started npc filtering [2016-03-04T16:54:22Z] Finished npc filtering [2016-03-04T16:54:22Z] Goblins found: 4 [2016-03-04T16:54:22Z] Exit onLoop [2016-03-04T16:54:23Z] Enter onLoop [2016-03-04T16:54:23Z] Started npc filtering [2016-03-04T16:54:23Z] Finished npc filtering [2016-03-04T16:54:23Z] Goblins found: 4 [2016-03-04T16:54:23Z] Exit onLoop [2016-03-04T16:54:24Z] Enter onLoop [2016-03-04T16:54:24Z] Started npc filtering [2016-03-04T16:54:24Z] Finished npc filtering [2016-03-04T16:54:24Z] Goblins found: 4 [2016-03-04T16:54:24Z] Exit onLoop [2016-03-04T16:54:24Z] Enter onLoop [2016-03-04T16:54:24Z] Started npc filtering [2016-03-04T16:54:24Z] Finished npc filtering [2016-03-04T16:54:24Z] Goblins found: 4 [2016-03-04T16:54:24Z] Exit onLoop [2016-03-04T16:54:25Z] Enter onLoop [2016-03-04T16:54:25Z] Started npc filtering [2016-03-04T16:54:25Z] Finished npc filtering [2016-03-04T16:54:25Z] Goblins found: 4 [2016-03-04T16:54:25Z] Exit onLoop [2016-03-04T16:54:25Z] Enter onLoop [2016-03-04T16:54:25Z] Started npc filtering [2016-03-04T16:54:25Z] Finished npc filtering [2016-03-04T16:54:25Z] Goblins found: 4 [2016-03-04T16:54:25Z] Exit onLoop [2016-03-04T16:54:26Z] Enter onLoop [2016-03-04T16:54:26Z] Started npc filtering [2016-03-04T16:54:26Z] Finished npc filtering [2016-03-04T16:54:26Z] Goblins found: 4 [2016-03-04T16:54:26Z] Exit onLoop [2016-03-04T16:54:26Z] Enter onLoop [2016-03-04T16:54:26Z] Started npc filtering [2016-03-04T16:54:26Z] Finished npc filtering [2016-03-04T16:54:26Z] Goblins found: 4 [2016-03-04T16:54:26Z] Exit onLoop [2016-03-04T16:54:27Z] Enter onLoop [2016-03-04T16:54:27Z] Started npc filtering [2016-03-04T16:54:27Z] Finished npc filtering [2016-03-04T16:54:27Z] Goblins found: 4 [2016-03-04T16:54:27Z] Exit onLoop [2016-03-04T16:54:27Z] Bye user [2016-03-04T16:54:27Z] Exit onExit [2016-03-04T16:54:27Z] LOG SESSION STOPPED After changing the processor levels to: logger.addProcessor(new OSBotLogProcessor(this, LOG_DEV_DEBUG)); logger.addProcessor(new TextFileLogProcessor(new File("C:/Users/bjorn/Desktop/TextTest.txt"), LOG_DEV_DEBUG)); OSBot log: [INFO][Bot #1][03/04 05:58:54 PM]: Started script : Simplog Example [INFO][Bot #1][03/04 05:58:54 PM]: Goblins found: 5 [INFO][Bot #1][03/04 05:58:55 PM]: Goblins found: 5 [INFO][Bot #1][03/04 05:58:55 PM]: Goblins found: 6 [INFO][Bot #1][03/04 05:58:56 PM]: Goblins found: 7 [INFO][Bot #1][03/04 05:58:56 PM]: Goblins found: 7 [INFO][Bot #1][03/04 05:58:57 PM]: Goblins found: 7 [INFO][Bot #1][03/04 05:58:57 PM]: Goblins found: 7 [INFO][Bot #1][03/04 05:58:58 PM]: Goblins found: 7 [INFO][Bot #1][03/04 05:58:58 PM]: Goblins found: 7 [INFO][Bot #1][03/04 05:58:59 PM]: Goblins found: 7 [INFO][Bot #1][03/04 05:58:59 PM]: Terminating script Simplog Example... [INFO][Bot #1][03/04 05:58:59 PM]: Bye user [INFO][Bot #1][03/04 05:58:59 PM]: Script Simplog Example has exited! File log: [2016-03-04T16:58:54Z] LOG SESSION STARTED [2016-03-04T16:58:54Z] Welcome user [2016-03-04T16:58:54Z] Goblins found: 5 [2016-03-04T16:58:55Z] Goblins found: 5 [2016-03-04T16:58:55Z] Goblins found: 6 [2016-03-04T16:58:56Z] Goblins found: 7 [2016-03-04T16:58:56Z] Goblins found: 7 [2016-03-04T16:58:57Z] Goblins found: 7 [2016-03-04T16:58:57Z] Goblins found: 7 [2016-03-04T16:58:58Z] Goblins found: 7 [2016-03-04T16:58:58Z] Goblins found: 7 [2016-03-04T16:58:59Z] Goblins found: 7 [2016-03-04T16:58:59Z] Bye user [2016-03-04T16:58:59Z] LOG SESSION STOPPED Edited March 4, 2016 by Botre 2 Quote Link to comment Share on other sites More sharing options...
Genii Posted March 4, 2016 Share Posted March 4, 2016 Why do you post these in spam? Quote Link to comment Share on other sites More sharing options...
Botre Posted March 4, 2016 Author Share Posted March 4, 2016 (edited) Why do you post these in spam? Spam felt safe, didn't want to flood the other sections with my daily code poop. (Also these are teasers, not actually snippets or finished products, hence the "T" ) Edited March 4, 2016 by Botre Quote Link to comment Share on other sites More sharing options...
Harry Posted March 4, 2016 Share Posted March 4, 2016 I wish I understood. Quote Link to comment Share on other sites More sharing options...
Salty as fuck Posted March 5, 2016 Share Posted March 5, 2016 (edited) "File("C:/Users/bjorn/Desktop/TextTest.txt")" nice name, fam Edited March 5, 2016 by Reminiscence Quote Link to comment Share on other sites More sharing options...
Botre Posted March 5, 2016 Author Share Posted March 5, 2016 "File("C:/Users/bjorn/Desktop/TextTest.txt")" nice name, fam That's me alright Quote Link to comment Share on other sites More sharing options...