An open API service indexing awesome lists of open source software.

https://github.com/djoezeke/celog

A Fast , Convenient and Lightweight Header Only C/C++ Logging Library.
https://github.com/djoezeke/celog

asynchronous c cpp cross-platform header-only high-performance logger logging logging-library low-latency

Last synced: over 1 year ago
JSON representation

A Fast , Convenient and Lightweight Header Only C/C++ Logging Library.

Awesome Lists containing this project

README

          

# Celog 📋

Celog is a lightweight logging library for C/C++ projects.
It provides various logging levels and supports colored and styled output for better readability.

## Features ✨

- Multiple log levels:
- EMERGENCY 🚨
- ALERT âš ī¸
- CRITICAL ❗
- ERROR ❌
- WARNING âš ī¸
- NOTICE đŸ“ĸ
- INFO â„šī¸
- DEBUG 🐛
- Colored and styled output 🎨
- File and function information in log messages 📂
- Configurable log level, color, and style settings âš™ī¸

## Installation đŸ› ī¸

To use Celog in your project, simply include the `celog.h` header file in your source files.

```cpp
#include "celog.h"
```

## Usage 📖

### Log Levels

Celog provides the following log levels:

- `celog_emerg`: Emergency messages 🚨
- `celog_alert`: Alert messages âš ī¸
- `celog_crit`: Critical messages ❗
- `celog_error`: Error messages ❌
- `celog_warn`: Warning messages âš ī¸
- `celog_notice`: Notice messages đŸ“ĸ
- `celog_info`: Informational messages â„šī¸
- `celog_debug`: Debug messages 🐛

### Example

```cpp
#include "celog.h"

int main() {
celog_emerg("This is an emergency message");
celog_alert("This is an alert message");
celog_crit("This is a critical message");
celog_error("This is an error message");
celog_warn("This is a warning message");
celog_notice("This is a notice message");
celog_info("This is an informational message");
celog_debug("This is a debug message");

return 0;
}
```

## Configuration âš™ī¸

You can configure the log level, color, and style settings by defining or uncommenting the following macros in `ceconfig.h`:

- `CELOG_LOG_LEVEL`: Set the log level (default: 7)
- `CELOG_COLOR`: Enable or disable colored output (default: 1)
- `CELOG_STYLE`: Enable or disable styled output (default: 1)

### Example Configuration

To customize the logging behavior, you can modify the `ceconfig.h` file:

```cpp
// Set the log level to WARNING
#define CELOG_LOG_LEVEL 4

// Disable file information in log messages
#define CELOG_NO_FILE_INFO

// Disable function information in log messages
#define CELOG_NO_FUNC_INFO
```

### Log Level Controls

Celog allows you to control the log levels by defining the `CELOG_LOG_LEVEL` macro.
Messages with a log level lower than the defined level will be disabled.

### Log Information Controls

Celog allows you to control the log information by defining:

- `CELOG_NO_FILE_INFO`: Disables logging of file information (file name and line number).
- `CELOG_NO_FUNC_INFO`: Disables logging of function information (function name).

### Color and Style Controls

You can disable colors and styles by setting `CELOG_COLOR` and `CELOG_STYLE` to 0, respectively.

## License 📄

This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.

## Contributing 🤝

Contributions are welcome! Please open an issue or submit a pull request on GitHub.

## Acknowledgements 🙏

Celog is inspired by various logging libraries and aims to provide a simple and lightweight solution for C/C++ projects.