Skip to content

Commit 6f6b19d

Browse files
Merge pull request #26 from AndreLaranjeira/development
Version 1.1.0 * Configurable color scheme for the Message Logger; * Project documentation; * Added copyright information directly to files; * Improved function prototypes; * General refactoring;
2 parents eceed82 + e6531b1 commit 6f6b19d

File tree

7 files changed

+4148
-140
lines changed

7 files changed

+4148
-140
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@ msg-logger-sample
66

77
# Log files:
88
*.log
9+
10+
# Project documentation:
11+
doc

Doxyfile

+2,596
Large diffs are not rendered by default.

Makefile

+41-8
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1+
# Copyright (c) 2019 André Filipe Caldas Laranjeira
2+
# MIT License
3+
4+
# Message Logger module - Project Makefile.
5+
16
# Executable name:
27
EXE = msg-logger-sample
38

4-
# Compiler name, source file extension and compilation data (flags and libs):
5-
CC = gcc
6-
EXT = .c
7-
CFLAGS = -Wall -g -I $(IDIR)
8-
LIBS = -lm -lpthread
9-
109
# Project paths:
10+
DOCDIR = doc
11+
DOCHTMLDIR = html
12+
DOCLATEXDIR = latex
1113
IDIR = include
1214
ODIR = src/obj
1315
SDIR = src
@@ -22,6 +24,12 @@ DEPS = $(patsubst %,$(IDIR)/%,$(_DEPS))
2224
OBJ = $(patsubst %,$(ODIR)/%,$(_OBJ))
2325
SRC = $(patsubst %,$(SDIR)/%,$(_SRC))
2426

27+
# Compiler name, source file extension and compilation data (flags and libs):
28+
CC = gcc
29+
EXT = .c
30+
CFLAGS = -Wall -g -I $(IDIR)
31+
LIBS = -lm -lpthread
32+
2533
# Object files compilation rule:
2634
$(ODIR)/%.o: $(SDIR)/%$(EXT) $(DEPS)
2735
@if [ ! -d $(ODIR) ]; then mkdir $(ODIR); fi
@@ -33,8 +41,33 @@ $(EXE): $(OBJ)
3341

3442
# List of aditional makefile commands:
3543
.PHONY: clean
44+
.PHONY: doc
3645

37-
# Command to clean object files and project executable:
46+
# Command to clean generated files:
3847
clean:
3948
@rm -f $(ODIR)/*.o *~ core
40-
@if [ -f $(EXE) ]; then rm $(EXE) -i; fi
49+
@rm -rf $(DOCDIR)
50+
@if [ -f $(EXE) ]; then \
51+
rm -i $(EXE); \
52+
fi
53+
54+
# Command to generate the documentation:
55+
doc:
56+
@doxygen ./Doxyfile > /dev/null
57+
58+
@echo ""
59+
@echo "Open documentation now?"
60+
@echo "h - Open HTML format"
61+
@echo "l - Open Latex format (pdflatex required to generate documentation)"
62+
@echo "n - No (DEFAULT)"
63+
64+
@read -p "Choice (h/l/n): " DOC_CHOICE_RAW; \
65+
DOC_CHOICE=$$(echo $$DOC_CHOICE_RAW | tr '[:upper:]' '[:lower:]'); \
66+
if [[ $$DOC_CHOICE == "h" ]]; then \
67+
xdg-open $(DOCDIR)/$(DOCHTMLDIR)/index.html > /dev/null 2>&1; \
68+
elif [[ $$DOC_CHOICE == "l" ]]; then \
69+
echo ""; \
70+
echo "Generating latex documentation..."; \
71+
$(MAKE) -C $(DOCDIR)/$(DOCLATEXDIR) > /dev/null; \
72+
xdg-open $(DOCDIR)/$(DOCLATEXDIR)/refman.pdf > /dev/null 2>&1; \
73+
fi

README.md

+49-14
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,53 @@
1-
# MessageLogger
1+
# Message Logger
22

33
## 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.
55

66
## 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

Comments
 (0)