I reached many points of difficulty in my early software projects where the only thing left to do was to resort to logging, to figure out what was going on. Soon I grew to enjoy logging and made it a key point when starting a new project. It is an extra pair of eyes to help you test—especially when you are not looking, such as when running a data collector continuously.
The Dart package logging
provides facilities for logging, however it does not do anything useful with the output, or to put it another way, the handling of the storage of the logging is entirely in the hands of the application.
Open up this chapter's Logging
folder, which is a standalone example containing a range of logging:
Logger log = new Logger('DataMonitor'); Logger.root.level = Level.ALL; Logger.root.onRecord.listen((LogRecord rec) { String logMessage = '${rec.level.name}\t${rec.time}\t\t${rec.message}'; String exceptionMessage = ''; if (rec.error != null) { ...