|
1 |
| -# MessageLogger |
| 1 | +# Message Logger |
2 | 2 |
|
3 | 3 | ## Description
|
4 |
| -A simple message logger for the C programming language with different message types. Meant to be used in everyday projects to simplify the task of printing messages to the user. |
| 4 | +A simple message logger for the C programming language with different message types. Meant to be used in everyday projects to simplify the task of printing messages to the user or saving them in a log file. |
5 | 5 |
|
6 | 6 | ## Features
|
7 |
| -- [x] Five different types of messages with context fields: message, success, warning, error and info. |
8 |
| -- [X] Public functions to color the text and the background, giving the programmer greater flexibility. |
9 |
| -- [X] Optional configuration to store logged messages in a separate file. |
10 |
| - - [X] Configurable time format for messages. |
11 |
| -- [x] Thread-safe message logging. |
12 |
| - |
13 |
| -## Sample file |
14 |
| -If you want to see this message logger in action, we have included the `sample.c` source code file, which showcases some features of the message logger developed, and a simple `Makefile` to allow the compilation of said source file into an executable. |
15 |
| - |
16 |
| -To sample the message logger, type the following commands on a *terminal* in the **project's root directory**: |
17 |
| -1. `make` |
18 |
| -2. `./msg-logger-sample` |
| 7 | +- Five different types of messages with context fields: message, success, warning, error and info. |
| 8 | +- Public functions to color the text and the background, giving the programmer greater flexibility. |
| 9 | +- Optional configuration to store logged messages in a separate log file. |
| 10 | + - Configurable time format for log file. |
| 11 | +- Thread-safe message logging. |
| 12 | +- Color customization for message types. |
| 13 | +- Full documentation provided. |
| 14 | + |
| 15 | +## How to use |
| 16 | + |
| 17 | +### Dependencies |
| 18 | + |
| 19 | +* `doxygen` - For generating documentation; |
| 20 | +* `gcc` - For compiling the sample file; |
| 21 | +* `libpthread` - For compiling the Message Logger module; |
| 22 | +* `pdflatex` \(optional\) - For compiling the documentation in the latex format; |
| 23 | + |
| 24 | +### Use it in your projects |
| 25 | + |
| 26 | +To use the Message Logger as a module in your project, follow the steps bellow: |
| 27 | + |
| 28 | +1. Copy the header file (`message_logger.h`) to your include directory and the source file (`message_logger.c`) to your source directory; |
| 29 | +2. Update any Makefiles, compilation instructions or other project settings to account for these files and to use the pthreads library in compilation with the flag `-lpthread`; |
| 30 | +3. Include the header file in your code with the command `#include "message_logger.h"`. |
| 31 | + |
| 32 | +Feel free to use, modify and examine the Message Logger's code in any way that is _in accordance with the project's MIT license_. |
| 33 | + |
| 34 | +### Generating documentation |
| 35 | + |
| 36 | +To generate the documentation for the Message Logger module, you will need to have the program `doxygen` installed and included in your $PATH. You will also need the program `pdflatex` installed and included in your $PATH if you want to compile the documentation in the latex format. |
| 37 | + |
| 38 | +Once you have installed the necessary dependencies, simply run the command `make doc`, on a shell from the **project's root directory**. This should generate documentation files both in the HTML and Latex formats. The makefile will then prompt you if you want to immediately open any of the generated documentation. |
| 39 | + |
| 40 | +To open the generated HTML documentation, open the file `doc/html/index.html`. To open the generated latex documentation, compile the latex files with the generated makefile by running `make` in the directory `doc/latex` and open the file `doc/latex/refman.pdf`. |
| 41 | + |
| 42 | +### Sample file |
| 43 | + |
| 44 | +If you want to see this Message Logger module in action, we have included the `sample.c` source code file, which showcases some of the available features in this Message Logger module. To compile this sample into an executable, you will need the program `gcc` installed and included in your $PATH. If you wish to use a different compiler, change the `CC` variable in the `Makefile` and make any appropriate changes to how this variable is called. |
| 45 | + |
| 46 | +To sample the Message Logger module, follow the commands bellow: |
| 47 | + |
| 48 | +1. Run the command `make`, on a shell from the **project's root directory** to compile said source file into an executable; |
| 49 | +2. Open the executable `msg-logger-sample` that was generated. |
| 50 | + |
| 51 | +### Cleaning up |
| 52 | + |
| 53 | +To clean up any object files, executables and documentation files, run the command `make clean`, on a shell from the **project's root directory**. |
0 commit comments