Update documentation
This commit is contained in:
parent
193ad83e10
commit
435a3eafbc
59
README.md
59
README.md
@ -1,2 +1,57 @@
|
||||
# cct
|
||||
Common C Tools
|
||||
# cct (Common C Tools)
|
||||
|
||||
This is a collection of useful and common C tools that can be installed and used in any C project using C99 or higher. The goal of this project is to provide a set of reusable and well-tested functions that can be easily integrated into various C projects.
|
||||
|
||||
## Library Structure
|
||||
|
||||
The CCT library is compiled into a static library, which includes several header files. The main header files are:
|
||||
|
||||
- [log.h](./log.h): Provides logging functionality with customizable log levels and output streams
|
||||
|
||||
## Installation
|
||||
|
||||
To install the CCT library, follow these steps:
|
||||
|
||||
1. Clone the repository:
|
||||
|
||||
```bash
|
||||
git clone https://github.com/vas-dav/cct.git
|
||||
```
|
||||
|
||||
2. Build the library:
|
||||
|
||||
```bash
|
||||
cd cct && make
|
||||
```
|
||||
|
||||
3. Install the library:
|
||||
|
||||
```bash
|
||||
make install
|
||||
```
|
||||
|
||||
## Using the library
|
||||
|
||||
> This example is trivial only created to get started.
|
||||
> More diverse use cases and documentation is available in [docs](./docs/).
|
||||
|
||||
Once the library is installed, it can be used in any source file as follows:
|
||||
|
||||
```c
|
||||
#include <cct/log.h>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
cct_log("Hello from CCT!");
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
And compiled inlcuding the library:
|
||||
|
||||
```bash
|
||||
<your_c_compiler> hello.c -lcct
|
||||
```
|
||||
|
||||
## Documentation
|
||||
|
||||
All of the documentation can be found [here](./docs/).
|
||||
|
||||
60
docs/log/README.md
Normal file
60
docs/log/README.md
Normal file
@ -0,0 +1,60 @@
|
||||
# CCT Logging API
|
||||
|
||||
This document provides a comprehensive overview of the logging API offered by the CCT library. The API encompasses various logging functions that facilitate the logging of messages at different severity levels.
|
||||
|
||||
## Macros
|
||||
|
||||
### #inlcude <cct/log.h>
|
||||
|
||||
### `cct_log`
|
||||
|
||||
Logs a plain message utilizing the specified format string and arguments.
|
||||
|
||||
- **Parameters:**
|
||||
- `fmt`: The format string for the log message.
|
||||
- `...`: The arguments to be utilized in the format string.
|
||||
|
||||
### `cct_info`
|
||||
|
||||
Logs an informational message utilizing the specified format string and arguments. This macro additionally traces the log line, function name, and file name.
|
||||
|
||||
- **Parameters:**
|
||||
- `fmt`: The format string for the log message.
|
||||
- `...`: The arguments to be utilized in the format string.
|
||||
|
||||
### `cct_warning`
|
||||
|
||||
Logs a warning message utilizing the specified format string and arguments. This macro also traces the log line, function name, and file name.
|
||||
|
||||
- **Parameters:**
|
||||
- `fmt`: The format string for the log message.
|
||||
- `...`: The arguments to be utilized in the format string.
|
||||
|
||||
### `cct_error`
|
||||
|
||||
Logs an error message utilizing the specified format string and arguments, and subsequently terminates the program. This macro traces the log line, function name, and file name.
|
||||
|
||||
- **Parameters:**
|
||||
- `fmt`: The format string for the log message.
|
||||
- `...`: The arguments to be utilized in the format string.
|
||||
|
||||
### `cct_debug`
|
||||
|
||||
Logs a debug message utilizing the specified format string and arguments. This macro also traces the log line, function name, and file name.
|
||||
|
||||
- **Parameters:**
|
||||
- `fmt`: The format string for the log message.
|
||||
- `...`: The arguments to be utilized in the format string.
|
||||
|
||||
## Features & Limitations
|
||||
|
||||
- All logging macros, with the exception of `cct_log`, will trace the log line, function name, and file name.
|
||||
- The total length of the message for any of the logging macros must not exceed 256 bytes.
|
||||
|
||||
## Usage
|
||||
|
||||
Check example in [here](./main.c).
|
||||
|
||||
## Conclusion
|
||||
|
||||
The CCT Logging API provides a straightforward and effective mechanism for logging messages of differing severity levels. By employing these macros, developers can efficiently monitor the execution flow of their applications and manage errors in a systematic manner.
|
||||
20
docs/log/main.c
Normal file
20
docs/log/main.c
Normal file
@ -0,0 +1,20 @@
|
||||
#include <cct/log.h>
|
||||
|
||||
int main() {
|
||||
// Log a plain message
|
||||
cct_log("This is a plain log message.\n");
|
||||
|
||||
// Log an info message
|
||||
cct_info("The value of pi is approximately %f.\n", 3.14159);
|
||||
|
||||
// Log a warning message
|
||||
cct_warning("The system is running low on memory.\n");
|
||||
|
||||
// Log an error message and exit the program
|
||||
cct_error("The system has encountered a fatal error.\n");
|
||||
|
||||
// Log a debug message
|
||||
cct_debug("Unreachable code");
|
||||
|
||||
return 0;
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user