Skip to content

Log.cc usage

Gordon Zhang edited this page Jul 29, 2024 · 7 revisions

Welcome to the log.cc wiki!

Usage

Note

The basic functions are introduced in README.md. Here I will tell you more functions defined in Log.cc.

The following examples use l as the default logger name.

Setting the log level

You can use the setLogLevel function.

Example

l.setLogLevel(WARNING);

Now only log message which are more important than (or as important as) Warning will me shown.

Getting the log level

Use function getLogLevel.

  • Return value: int

Disable

You can use the disable function. Example: l.disable(); To enable the logger again, use the enable function.

Disable the terminal output

Tip

Sometimes, it's necessary to disable the terminal log output (especially when developing a GUI app, users don't want to see a terminal with plenty of messages).

l.disableTerminalOutput();

To enable terminal output again, use the enableTerminalOutput function.

Automatically generate a filename

Use function generateFilename

Arguments

  • string name:

The name of your application, "log" by default

  • string filenameExtension:

The filename extension for your log file, "txt" by default. Note that you don't have to include a dot in it. Filename extensions do not matter for Unix-like Operating Systems. However, it will be greate to customize your own filename extension, you may want something like ".log" instead of ".txt".

More info

You can view log.cc and log.h in the src/ dir.