The basic idea behind Sawzall programming is to write a series of code snippets, using the SZL library, to run through a log file as a series of logical operations. In other words, instead of interpreting the log message, or using any sort of format-aware text processor, the Sawzall interpreter looks at the log messages as if it were a series of instructions to perform. Each operation is separated by blank lines, so there is no need to read anything in between. This means that a log file is extremely efficient for storing large amounts of data, but also that a log message can be processed very quickly.
As each operation is performed, the log messages themselves are sent over the network to various logging service providers. When they receive a message from Google, they then compile it and return it to your computer. This saves you a tremendous amount of time, because it means that a log message will never be processed twice. Instead of having to scan through every single log for each message, a single log message can be received multiple times by different logging service providers, making processing a log message much quicker.
Unlike other log processing libraries, the Sawzall language does not have a built-in support for writing log messages to multiple formats. This means that you cannot use the Ruby language to create a log message and then have it sent to a variety of log readers and collectors. To do this, you have to either use a specialized logger for the format, or use the Ruby on Rails. framework to send your message to the right logging service provider.
The SZL library itself was designed to make the process of generating SZL logs much faster than the standard logger tools that exist today. It is written in a modular fashion, allowing programmers to add their own extensions and functionality as they wish. The Sawzall library contains the basic building blocks necessary to get started, so that you don’t have to learn how to build a log message from scratch to use the language. Once you’ve got the basic structure working, you can add more complex features, such as:
Many of the more advanced log message generation methods require a little bit of code to get started. The simplest log message generation tool, the logcat, will create the log message that is shown on your browser. If you’ve got an SMLN membership, you can also generate an SMLN log message directly from the logcat. file, which can be useful for tracking back-office changes. This method is available with any logging service provider, but is not included in the SZL library.
Some logging services will allow you to send all log messages to your email account, which is very convenient. However, if you want to view the log messages in a text format, the SZL library provides an extension to allow you to view these log messages directly from your text editor of choice. The library also includes a “Print” button to print out a log message, which is extremely handy when debugging log messages.