Une lib de log simple d'utilisation nécéssitant gint.
Go to file
Milan f2ead3c6c5 fixes to get it working with gint v2 2020-11-11 14:59:17 +01:00
demo Add demo 2020-04-04 14:35:39 +02:00
.gitignore add demo build files to gitignore 2020-04-04 14:38:13 +02:00
LICENSE Update LICENSE 2020-01-05 20:55:37 +01:00
Makefile Update Makefile 2020-01-05 20:54:37 +01:00
README.md add license to readme 2020-04-04 14:40:52 +02:00
configure add fxcg compatibility 2019-09-20 13:22:16 +02:00
liblog.c fixes to get it working with gint v2 2020-11-11 14:59:17 +01:00
liblog.h /!\ updates in function names 2020-04-04 14:35:22 +02:00

README.md

liblog: Virtual stream for logging

This library has been written to provide a sample stream, like a simplified printf to make on calc debug easier. It uses gint, and it is compatible with fxcg50 & fx9860g models. It currenlty supports:

  • Virtual stream with custom priorities for messages
  • Dynamic weight in ram (maximum 1Ko for fx9860g and maximum 4Ko for fxcg50)
  • Basic display functions for the stream
  • Function for exceptions

All this stuff is under GNU General Public License 3. Have fun ! ;p

Install

First, clone the project and then cd into the library directory. Then, you will have to configure and then install.

fx9860g models

./configure --fx9860g
make && make install

fxcg50 models

./configure --fxcg50
make && make install

Now, you have installed the library in your compiler. You can now use it in projects.

Note: the library can be installed for both platforms at the same time, installing one will not overwrite the other build.

Tutorial

We'll see how tu use the library in a sample project. :)

Configure project

You have to link the library in the project so you can use it in compilation ;) You just have to add one word in the project.cfg file:

# Libraries. Add one -l option for each library you are using, and also
# suitable -L options if you have library files in custom folders. To use
# fxlib, add libfx.a to the project directory and use "-L . -lfx".
LIBS_FX :=
LIBS_CG :=

Just add the word -llog-fx and -llog-cg to the lines. Once it is modified it should be like this:

# Libraries. Add one -l option for each library you are using, and also
# suitable -L options if you have library files in custom folders. To use
# fxlib, add libfx.a to the project directory and use "-L . -lfx".
LIBS_FX := -llog-fx
LIBS_CG := -llog-cg

Before using it, you have to write at the beginning of your source file:

#include <liblog.h>

To initialize or reset the log, use log_clear() function, for example in main.c.

Write text

You can easily send text to the stream with ll_send(). However, you can set a priority to this message. The different priority levels are:

  • LEVEL_INFO (if don't want to use the priorty levels, use it)
  • LEVEL_WARNING
  • LEVEL_CRITICAL
  • LEVEL_FATAL The print function is easy to use:
ll_send(priority, "Your text");

For example, I want to send a warning because a file doesn't exist, I just have to write:

ll_send(LEVEL_WARNING, "Can't read file %s (ErrCode=%d)", filename, code);

You can note that it uses the same syntax as printf, because it uses sprintf() from gint. So you can enter all the types or arguments that gint supports. :p

Change priority

You can also set the mimimal priorty level that the log accepts with void ll_set_level(log_level_t);. You can suspend it with ll_set_level(LEVEL_QUIET);, and at any moment change the priority to reaccept new messages. You can also get the current priorty with ll_get_level(void). If you don't use priority, the only level you use is LEVEL_INFO, so to restart it, use ll_set_level(LEVEL_INFO); ;)

Display log

Just call ll_display() to draw the last lines. It is a "one frame" function, there is no input management. To scroll, just use ll_pause(); which allows to use the arrows to scroll. To get out this function, use the [EXIT] key.

Enable panic function

You just have to run once ll_set_panic();. After this, if there is any "System Error", the log will be displayed and you could track the bug.