Hi fellow developers!
We have just released a new plugin, Logger.
https://marketplace.coronalabs.com/plugin/logger
In short Logger is created to help and speed up troubleshooting corona applications.
Before logger we had log files looking like this:
09:45:11.557 : loading
09:45:11.563 : beforeInitiAds
09:45:11.600 : afterInitAds
09:45:12.601 : before init purchases
09:45:12.622 : has init purchases true
09:45:12.651 : after init purchases
09:45:12.517 : load state
09:45:12.520 : state loaded
09:45:12.520 : state is now set
09:45:12.521 : start timer
09:45:12.522 : 1
09:45:12.522 : 2
…
and so on… the above logs are both excessive and unclear.
With Logger the logs are cleaner, tells you where in code it is called and gives you a good overview just by glancing at the log tag / channel, eg. [main]
03:18:11.712 /LOG: [main] Initializing analytics (main.lua:143)
03:18:11.712 /LOG: [state] initialize state (lib/configuration/state.lua:init:123)
03:18:11.726 /LOG: [crosspromo] init (lib/crosspromo/CrossPromo.lua:init:195)
03:18:11.726 /DEBUG: [crosspromo] Initializing Cross promo for store google (lib/crosspromo/CrossPromo.lua:init:197)
03:18:11.726 /LOG: [crosspromo] Cross promo data loaded successfully (lib/crosspromo/CrossPromo.lua:loadCrossPromoData:165)
03:18:11.726 /DUMP: [state] [xp_download_time] 1485958687 (lib/configuration/state.lua:get:102)
So what did we achieve:
- We see exactly where we are in source code
- The channel / tag of each log message provides clear information about what the message is related to
- Log messages can be filtered based on channel and log level, eg. in the example above we have filtered out DEBUG and DUMP for channel [main]. This makes is A LOT easier to troubleshoot specific issues.
Among the list of features
-
See where in code the log statement is made, eg. path, file, function and line in file.
-
Setup log channels / tags - This allows filtering of log messages depending on what you are interested at this time and a much clearer log where you can easily see what the log message is related
-
Write to console with the following log levels: Error, Warning, Log, Debug, Dump
-
Highlight warnings / errors
-
Use different log setups for simulator, device, etc.
-
Log complex messages like multiple arguments, tables, etc. etc.
Quick start
- build.settings - Include the plugin in build settings
-
- [‘plugin.logger’] = {publisherId = 'com.yogergames’},
- initialize
-
- local logger = require(“plugin.logger”)
- local logOptions = {}
- logOptions.highlight_errors = true
- logOptions.highlight_warnings = true
- logOptions.log_levels = {
- global = logger.LEVELS.WARNING, – Will set log level WARNING for GLOBAL channel
- main = logger.LEVELS.DUMP
- }
- logger.init(logOptions)
- start logging
-
- logger.error(“main”, “print an error from channel main”)
- logger.warning(“main”, "print a warning from channel main”)
- logger.log(“main”, "print a log message from channel main”)
- logger.debug(“main”, "print a debug message from channel main”)
- logger.dump(“main”, “print a dump message from channel main”)
Initially the plugin will be free.
If you have any questions, feel free to send a message or write below.
You can also send us an email at support@yogergames.com