Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## Header inclusion
This project provides dedicated entry-point headers that include internal dependencies in the correct order. Use these headers instead of forward-declaring library types.

* `include/logit_cpp/LogIt.hpp` – main entry for the entire library.
* `include/logit_cpp/logit.hpp` – main entry for the entire library.
* `include/logit_cpp/logit/utils.hpp` – aggregates the utilities module.

Including through these headers ensures dependencies are resolved without manual forward declarations.
Expand All @@ -16,3 +16,9 @@ Include a body that describes the change.
## Changes
Keep diffs minimal and focused.
Do not refactor or apply style changes beyond the lines you directly touch.

## Header naming conventions
When adding or renaming headers, follow these rules:

* If the file defines a single primary class (with optional supporting enums or helper functions dedicated to that class), use a PascalCase filename.
* If the file hosts multiple classes, macros, free functions, or otherwise represents a mixed collection of declarations, use a snake_case filename.
20 changes: 10 additions & 10 deletions README-RU.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

Ключевые особенности:

- **Макро-ориентированный API.** Единые семейства макросов (`LOGIT_<LEVEL>`, `LOGIT_PRINTF_<LEVEL>`, `LOGIT_STREAM_<LEVEL>` и др.) покрывают мгновенные сообщения, форматирование в стиле `printf`, потоковый вывод, ограничения частоты и работу с тегами. Определите `LOGIT_SHORT_NAME` перед подключением `<LogIt.hpp>`, чтобы включить компактные алиасы `LOG_I`, `LOG_WPF`, `LOG_S_INFO` и другие.
- **Макро-ориентированный API.** Единые семейства макросов (`LOGIT_<LEVEL>`, `LOGIT_PRINTF_<LEVEL>`, `LOGIT_STREAM_<LEVEL>` и др.) покрывают мгновенные сообщения, форматирование в стиле `printf`, потоковый вывод, ограничения частоты и работу с тегами. Определите `LOGIT_SHORT_NAME` перед подключением `<logit.hpp>`, чтобы включить компактные алиасы `LOG_I`, `LOG_WPF`, `LOG_S_INFO` и другие.
- **Гибкое форматирование и маршрутизация.** Настраивайте шаблоны формата, комбинируйте консольные/файловые/системные бэкенды или подключайте собственные реализации логгеров.
- **Асинхронность по умолчанию.** Каждый бэкенд обслуживается исполнителем задач с настраиваемыми размерами очереди и политиками переполнения, а макросы вроде `LOGIT_WARN_ONCE` или `LOGIT_ERROR_THROTTLE` помогают упорядочить повторяющиеся сообщения.

Expand All @@ -18,7 +18,7 @@
### Полные макросы

```cpp
#include <LogIt.hpp>
#include <logit.hpp>

int main() {
LOGIT_ADD_CONSOLE_DEFAULT();
Expand Down Expand Up @@ -46,11 +46,11 @@ int main() {

### Короткие алиасы

Определите `LOGIT_SHORT_NAME` перед подключением `<LogIt.hpp>`, чтобы использовать односимвольные префиксы уровней:
Определите `LOGIT_SHORT_NAME` перед подключением `<logit.hpp>`, чтобы использовать односимвольные префиксы уровней:

```cpp
#define LOGIT_SHORT_NAME
#include <LogIt.hpp>
#include <logit.hpp>

void short_names_demo() {
LOGIT_ADD_CONSOLE_DEFAULT(); // вызывайте один раз при инициализации
Expand All @@ -72,7 +72,7 @@ void short_names_demo() {
`LOGIT_SYSERR_<LEVEL>` захватывает текущее значение `errno` (или `GetLastError()` в Windows) и добавляет расшифровку ошибки к исходному сообщению, чтобы в логе оставался как контекст, так и код сбоя. При необходимости можно явно выбрать платформу через `LOGIT_PERROR_<LEVEL>` или `LOGIT_WINERR_<LEVEL>`.

```cpp
#include <LogIt.hpp>
#include <logit.hpp>
#include <fcntl.h>

int main() {
Expand All @@ -92,7 +92,7 @@ int main() {
#define LOGIT_OS_ERROR_JOIN " <- "
#define LOGIT_POSIX_ERROR_PATTERN "[%s] errno=%d (%s)"
#define LOGIT_WINDOWS_ERROR_PATTERN "[%s] GetLastError=%lu (%s)"
#include <LogIt.hpp>
#include <logit.hpp>

// ... далее в коде ...
LOGIT_SYSERR_ERROR("Ошибка удаления временного каталога");
Expand Down Expand Up @@ -258,7 +258,7 @@ LOGIT_ADD_LOGGER(CustomLogger, (), logit::SimpleLogFormatter, ("%v"));

```cpp
#define LOGIT_SHORT_NAME
#include <LogIt.hpp>
#include <logit.hpp>

int main() {
LOGIT_ADD_CONSOLE_DEFAULT();
Expand Down Expand Up @@ -569,7 +569,7 @@ LogIt++ предоставляет несколько макросов, кото
```cpp
#include <fstream>
#include <mutex>
#include <LogIt.hpp>
#include <logit.hpp>

class FileLogger : public logit::ILogger {
public:
Expand Down Expand Up @@ -602,7 +602,7 @@ private:
### Пример пользовательского форматтера

```cpp
#include <LogIt.hpp>
#include <logit.hpp>
#include <json/json.h>

class JsonLogFormatter : public logit::ILogFormatter {
Expand Down Expand Up @@ -636,7 +636,7 @@ git clone --recurse-submodules https://github.com/NewYaroslav/log-it-cpp.git
2. Включите заголовочные файлы LogIt++ в ваш проект:

```cpp
#include <LogIt.hpp>
#include <logit.hpp>
```

3. Настройте пути к заголовочным файлам для зависимостей, таких как time-shield-cpp.
Expand Down
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

Key characteristics:

- **Macro-oriented API.** Consistent macro families (`LOGIT_<LEVEL>`, `LOGIT_PRINTF_<LEVEL>`, `LOGIT_STREAM_<LEVEL>`, etc.) cover immediate messages, printf-style formatting, streaming, throttling, and tagging. Defining `LOGIT_SHORT_NAME` when including `<LogIt.hpp>` enables compact aliases like `LOG_I`, `LOG_WPF`, and `LOG_S_INFO`.
- **Macro-oriented API.** Consistent macro families (`LOGIT_<LEVEL>`, `LOGIT_PRINTF_<LEVEL>`, `LOGIT_STREAM_<LEVEL>`, etc.) cover immediate messages, printf-style formatting, streaming, throttling, and tagging. Defining `LOGIT_SHORT_NAME` when including `<logit.hpp>` enables compact aliases like `LOG_I`, `LOG_WPF`, and `LOG_S_INFO`.
- **Flexible formatting and routing.** Customize output patterns, mix console/file/system backends, or supply custom logger implementations.
- **Async by default.** Each backend is served by the task executor with configurable queue sizes and overflow policies, plus helpers such as `LOGIT_WARN_ONCE` or `LOGIT_ERROR_THROTTLE` to keep repeated messages under control.

Expand All @@ -27,7 +27,7 @@ See the macro examples below or browse the `examples/` folder for focused demons
### Long-form macros

```cpp
#include <LogIt.hpp>
#include <logit.hpp>

int main() {
LOGIT_ADD_CONSOLE_DEFAULT();
Expand Down Expand Up @@ -55,11 +55,11 @@ int main() {

### Short aliases

Define `LOGIT_SHORT_NAME` before including `<LogIt.hpp>` to enable single-letter level prefixes:
Define `LOGIT_SHORT_NAME` before including `<logit.hpp>` to enable single-letter level prefixes:

```cpp
#define LOGIT_SHORT_NAME
#include <LogIt.hpp>
#include <logit.hpp>

void short_names_demo() {
LOGIT_ADD_CONSOLE_DEFAULT(); // call once during initialization
Expand All @@ -81,7 +81,7 @@ For a standalone program that brings everything together and intentionally abort
`LOGIT_SYSERR_<LEVEL>` captures the current `errno` (or `GetLastError()` on Windows) and appends the decoded information to the message, so failure details stay attached to the original context. The lower-level `LOGIT_PERROR_<LEVEL>` and `LOGIT_WINERR_<LEVEL>` families are also available if you want to explicitly choose the platform macro.

```cpp
#include <LogIt.hpp>
#include <logit.hpp>
#include <fcntl.h>

int main() {
Expand All @@ -101,7 +101,7 @@ The error suffix can be customised at compile time via `config.hpp` macros:
#define LOGIT_OS_ERROR_JOIN " <- "
#define LOGIT_POSIX_ERROR_PATTERN "[%s] errno=%d (%s)"
#define LOGIT_WINDOWS_ERROR_PATTERN "[%s] GetLastError=%lu (%s)"
#include <LogIt.hpp>
#include <logit.hpp>

// ... later in the code ...
LOGIT_SYSERR_ERROR("Deleting temp directory failed");
Expand Down Expand Up @@ -232,7 +232,7 @@ Here’s a simple example demonstrating how to use LogIt++ in your application.

```cpp
#define LOGIT_SHORT_NAME
#include <LogIt.hpp>
#include <logit.hpp>

int main() {
// Initialize the logger with default console output
Expand Down Expand Up @@ -545,7 +545,7 @@ You can extend LogIt++ by implementing your own loggers and formatters. Here’s
```cpp
#include <fstream>
#include <mutex>
#include <LogIt.hpp>
#include <logit.hpp>

class FileLogger : public logit::ILogger {
public:
Expand Down Expand Up @@ -578,7 +578,7 @@ private:
### Custom Formatter Example

```cpp
#include <LogIt.hpp>
#include <logit.hpp>
#include <json/json.h>

class JsonLogFormatter : public logit::ILogFormatter {
Expand Down Expand Up @@ -662,7 +662,7 @@ git clone --recurse-submodules https://github.com/NewYaroslav/log-it-cpp.git
2. Include the LogIt++ headers in your project:

```cpp
#include <LogIt.hpp>
#include <logit.hpp>
```

3. Set up include paths for dependencies like time-shield-cpp.
Expand Down
2 changes: 1 addition & 1 deletion docs/groups.dox
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ if (fd == -1) {
\endcode
Customise the suffix by overriding configuration macros such as
`LOGIT_OS_ERROR_JOIN`, `LOGIT_POSIX_ERROR_PATTERN`, or `LOGIT_WINDOWS_ERROR_PATTERN`
before including `<LogIt.hpp>`.
before including `<logit.hpp>`.

\par Logger Management
\code
Expand Down
16 changes: 8 additions & 8 deletions docs/mainpage.dox
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Version: VERSION_PLACEHOLDER

Key characteristics:

- **Macro-oriented API.** Consistent macro families (`LOGIT_<LEVEL>`, `LOGIT_PRINTF_<LEVEL>`, `LOGIT_STREAM_<LEVEL>`, etc.) cover immediate messages, `printf`-style formatting, streaming, throttling, and tagging. Defining `LOGIT_SHORT_NAME` when including `<LogIt.hpp>` enables compact aliases like `LOG_I`, `LOG_WPF`, and `LOG_S_INFO`.
- **Macro-oriented API.** Consistent macro families (`LOGIT_<LEVEL>`, `LOGIT_PRINTF_<LEVEL>`, `LOGIT_STREAM_<LEVEL>`, etc.) cover immediate messages, `printf`-style formatting, streaming, throttling, and tagging. Defining `LOGIT_SHORT_NAME` when including `<logit.hpp>` enables compact aliases like `LOG_I`, `LOG_WPF`, and `LOG_S_INFO`.
- **Flexible formatting and routing.** Customize output patterns, mix console/file/system backends, or supply custom logger implementations.
- **Async by default.** Each backend is served by the task executor with configurable queue sizes and overflow policies, plus helpers such as `LOGIT_WARN_ONCE` or `LOGIT_ERROR_THROTTLE` to keep repeated messages under control.

Expand All @@ -20,7 +20,7 @@ See the macro examples below or browse the `examples/` directory for focused dem
\subsection macro_examples_long Long-form macros

\code{.cpp}
#include <LogIt.hpp>
#include <logit.hpp>

int main() {
LOGIT_ADD_CONSOLE_DEFAULT();
Expand Down Expand Up @@ -48,11 +48,11 @@ int main() {

\subsection macro_examples_short Short aliases

Define `LOGIT_SHORT_NAME` before including `<LogIt.hpp>` to enable single-letter level prefixes:
Define `LOGIT_SHORT_NAME` before including `<logit.hpp>` to enable single-letter level prefixes:

\code{.cpp}
#define LOGIT_SHORT_NAME
#include <LogIt.hpp>
#include <logit.hpp>

void short_names_demo() {
LOGIT_ADD_CONSOLE_DEFAULT(); // call once during initialization
Expand Down Expand Up @@ -177,7 +177,7 @@ Here's a simple example demonstrating how to use LogIt++ in your application:

\code{.cpp}
#define LOGIT_SHORT_NAME
#include <LogIt.hpp>
#include <logit.hpp>

int main() {
// Initialize the logger with default console output
Expand Down Expand Up @@ -521,7 +521,7 @@ To create a custom logger backend, you need to implement the `ILogger` interface
\code{.cpp}
#include <fstream>
#include <mutex>
#include <LogIt.hpp>
#include <logit.hpp>

class FileLogger : public logit::ILogger {
public:
Expand Down Expand Up @@ -575,7 +575,7 @@ logit::Logger::get_instance().add_logger(
In addition to creating custom loggers, you can also create custom formatters by implementing the `ILogFormatter` interface. Here's an example of a simple formatter that outputs log messages in JSON format:

\code{.cpp}
#include <LogIt.hpp>
#include <logit.hpp>
#include <json/json.h> // Or your preferred JSON library

class JsonLogFormatter : public logit::ILogFormatter {
Expand Down Expand Up @@ -646,7 +646,7 @@ git submodule update
Since LogIt++ is a header-only library, you can simply include the main header in your project:

\code{cpp}
#include <LogIt.hpp>
#include <logit.hpp>
\endcode

This will give you access to the entire logging system.
Expand Down
15 changes: 12 additions & 3 deletions examples/example_logit_basic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,17 @@

#include <iostream>
#include <stdexcept>
#include <LogIt.hpp>
#include <logit/test/loggers/file/file/file/test_log_depth_3.hpp>
#include <logit.hpp>

namespace {

void log_depth_fixture()
{
LOGIT_TRACE0();
LOGIT_TRACE("This is an informational message");
}

} // namespace

// Example enumeration
enum class COLORS {
Expand Down Expand Up @@ -77,7 +86,7 @@ int main() {
LOGIT_SET_MAX_QUEUE(64);
LOGIT_SET_QUEUE_POLICY(LOGIT_QUEUE_DROP);

logit::test_log_depth_3();
log_depth_fixture();

LOGIT_TRACE0();

Expand Down
2 changes: 1 addition & 1 deletion examples/example_logit_compression.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/// \file example_logit_compression.cpp
/// \brief Demonstrates file log compression using gzip.

#include <LogIt.hpp>
#include <logit.hpp>

int main() {
logit::FileLogger::Config cfg;
Expand Down
2 changes: 1 addition & 1 deletion examples/example_logit_custom_backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include <iostream>
#include <sstream>
#include <LogIt.hpp>
#include <logit.hpp>


/// \cond
Expand Down
2 changes: 1 addition & 1 deletion examples/example_logit_customized.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#define LOGIT_UNIQUE_FILE_LOGGER_PATH "E:\\logs\\unique_logs" // Custom path for unique file logger
#define LOGIT_FILE_LOGGER_AUTO_DELETE_DAYS 10 // Auto-delete logs older than 10 days

#include <LogIt.hpp>
#include <logit.hpp>
#include <iostream>
#include <stdexcept>

Expand Down
2 changes: 1 addition & 1 deletion examples/example_logit_minimal_crash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <cstdlib>

#define LOGIT_SHORT_NAME
#include <LogIt.hpp>
#include <logit.hpp>

namespace {

Expand Down
2 changes: 1 addition & 1 deletion examples/example_logit_queue_limit.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/// \file example_logit_queue_limit.cpp
/// \brief Shows how to limit the log queue size.

#include <LogIt.hpp>
#include <logit.hpp>

int main() {
LOGIT_ADD_CONSOLE_DEFAULT();
Expand Down
2 changes: 1 addition & 1 deletion examples/example_logit_short_macros.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define LOGIT_SHORT_NAME // Enable short macros

#include <iostream>
#include <LogIt.hpp>
#include <logit.hpp>

#define UNIQUE_LOGGER_ID 2

Expand Down
2 changes: 1 addition & 1 deletion examples/example_logit_system_logger.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/// \file example_logit_system_logger.cpp
/// \brief Demonstrates usage of the cross-platform SystemLogger.

#include <LogIt.hpp>
#include <logit.hpp>

int main() {
LOGIT_ADD_LOGGER(logit::SystemLogger, (), logit::SimpleLogFormatter, (LOGIT_CONSOLE_PATTERN));
Expand Down
10 changes: 5 additions & 5 deletions include/logit_cpp/LogIt.hpp → include/logit_cpp/logit.hpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#pragma once
#ifndef _LOGIT_HPP_INCLUDED
#define _LOGIT_HPP_INCLUDED
#ifndef LOGIT_CPP_LOGIT_HPP
#define LOGIT_CPP_LOGIT_HPP

/// \file LogIt.hpp
/// \file logit.hpp
/// \brief Main header file for the LogIt++ library.

#include "logit/config.hpp"
Expand All @@ -11,12 +11,12 @@
#include "logit/Logger.hpp"
#include "logit/LogStream.hpp"
#include "logit/detail/ScopeTimer.hpp"
#include "logit/LogMacros.hpp"
#include "logit/log_macros.hpp"
#include "logit/formatter.hpp"
#include "logit/loggers.hpp"

/// \namespace logit
/// \brief The primary namespace for the LogIt++ library.
namespace logit {};

#endif // _LOGIT_HPP_INCLUDED
#endif // LOGIT_CPP_LOGIT_HPP
Loading
Loading