This Atom is Under Construction

Logging reports information about a running program.

In a debugged program, this can be ordinary status data showing the progress of the program (for example, an installation program may log the steps taken during installation, the directories where you stored files, startup values for the program, etc.).

Logging is also helpful during debugging. Without logging, you might try to decipher the behavior of a program by inserting println() statements. Some examples in this book use that very technique, and in the absence of a debugger (like the one built into JetBrains IDEA), it’s about all you have. However, once you decide the program is working properly, you’ll probably take the println() statements out. Then if you run into more bugs, you may need to put them back in. It’s much nicer if you include output statements that are only used when necessary.

In some cases, all you can do when you discover an issue is report it. In a web application, for example, there’s no option to shut down the program if something goes wrong. Logging records such events, giving the programmer and/or administrator of the application yet another tool to discover problems.

End of sample. See AtomicKotlin.com for full early-access book.

Previous          Next

©2018 Mindview LLC. All Rights Reserved.