40. Programming part 1: Debugging logs

iFun Engine uses Google glog for programming debugging. For more details on Glog, refer to Glog documentation.

Supported log levels are INFO, WARNING, ERROR, and FATAL, and a simple explanation of their use follows.

40.1. Example of Google logging use

1
2
3
4
5
6
7
8
void some_function() {
  LOG(INFO) << "INFO level message. It does not require a new line.";
  LOG(WARNING) << "WARNING level message.";
  LOG(ERROR) << "ERROR level message.";

  // DLOG works only in the debugging mode.
  DLOG(INFO) << "DLOG gets elimiated if built with NDEBUG.";
}
1
2
3
4
5
6
void SomeFunction()
{
  Log.Info ("INFO level message. It does not require a new line.");
  Log.Warning ("WARNING level message.");
  Log.Error ("ERROR level message.");
}

40.2. Log file location

The location glog is created by iFun Engine is as follows.

  • At the development stage, a build directory is created under glog/.
  • At the live stage, it is under /var/log/funapi/{{ project_name }}/glog.

40.3. Outputting log messages on the screen

To output the log on a console screen rather than as a file in the development and testing stages, you can add --logotostderr or --alsologtostderr while running. The former generates the log only on the screen without generating a file, while the latter outputs the log as a file and on the screen.

$./my_server-local --logtostderr
$./my_server-local --alsologtostderr

40.4. Log function parameters

Add the following to a MANIFEST.json Logging session.

Parameters with configurations that are almost never changed manually

  • glog_flush_interval: Cycle in seconds to flush Google logging. (type=int32, default=1)
  • glog_retention_period_in_days: Google log file retention time. Glog files past their expiration date are deleted. (type=int32, default=30)