Skip to content

Commit

Permalink
merge and correct build
Browse files Browse the repository at this point in the history
  • Loading branch information
goatshriek committed Nov 28, 2024
2 parents d5926ce + f75f182 commit cd2c7ac
Show file tree
Hide file tree
Showing 33 changed files with 478 additions and 221 deletions.
4 changes: 2 additions & 2 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: Stumpless Logging Library
license: Apache-2.0
repository-code: "https://github.com/goatshriek/stumpless"
version: 3.0.0
date-released: 2024-06-30
date-released: 2024-11-28
keywords:
- journald
- logging
Expand All @@ -20,4 +20,4 @@ type: software
authors:
- given-names: Joel
family-names: Anderson
email: joelanderson333@gmail.com
email: joel@goatshriek.com
25 changes: 23 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
cmake_minimum_required(VERSION 3.2.3)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)

if(POLICY CMP0135)
cmake_policy(SET CMP0135 NEW)
endif()
Expand Down Expand Up @@ -294,6 +297,14 @@ endif()


# configuration-specific source files

# we don't check for win32 as on win32 socket operations are handled directly through return values
# Check if SO_NOSIGPIPE exists
check_symbol_exists(SO_NOSIGPIPE "sys/socket.h" HAVE_SO_NOSIGPIPE)

# Check if MSG_NOSIGNAL exists
check_symbol_exists(MSG_NOSIGNAL "sys/socket.h" HAVE_MSG_NOSIGNAL)

if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
set(SUPPORT_ABSTRACT_SOCKET_NAMES TRUE)
list(APPEND STUMPLESS_SOURCES ${PROJECT_SOURCE_DIR}/src/config/abstract_socket_names_supported.c)
Expand Down Expand Up @@ -836,7 +847,9 @@ add_function_test(current_target
)

add_function_test(element
SOURCES test/function/element.cpp
SOURCES
test/function/element.cpp
$<TARGET_OBJECTS:test_helper_fixture>
)

add_function_test(element_leak
Expand Down Expand Up @@ -1047,7 +1060,9 @@ add_function_test(memory
)

add_function_test(param
SOURCES ${PROJECT_SOURCE_DIR}/test/function/param.cpp
SOURCES
${PROJECT_SOURCE_DIR}/test/function/param.cpp
$<TARGET_OBJECTS:test_helper_fixture>
)

add_function_test(perror
Expand Down Expand Up @@ -1156,6 +1171,12 @@ add_performance_test(function
$<TARGET_OBJECTS:test_helper_fixture>
)

add_performance_test(buffer
SOURCES
${PROJECT_SOURCE_DIR}/test/performance/target/buffer.cpp
$<TARGET_OBJECTS:test_helper_fixture>
)

add_performance_test(log
SOURCES test/performance/log.cpp
)
Expand Down
18 changes: 17 additions & 1 deletion ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,23 @@ fixes, check out the
[roadmap](https://github.com/goatshriek/stumpless/blob/master/docs/roadmap.md).


## [3.0.0] - 2024-06-30
## [3.0.0] - 2024-11-28
### Added
- Colorization of output in stream targets via ANSI color codes, along with
supporting functions `stumpless_set_severity_color`.
- Memory allocation function accessors:
* `stumpless_get_free`
* `stumpless_get_malloc`
* `stumpless_get_realloc`
- Other new functions:
* `stumpless_get_priority_string`

### Fixed
- Strings that are a case-insensitive prefix of a valid severity string are
no longer accepted by severity from string functions.
- Memory leak in slab cache expansion.
- Use `SO_NOSIGPIPE` where `MSG_NOSIGNAL` is not defined.

### Removed
- `stumpless/priority.h`, which was merged into `stumpless/prival.h`.

Expand Down
36 changes: 18 additions & 18 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ cd build
cmake ../stumpless

# building the library itself
make all
cmake --build .
```

Other environments should be built according to their normal style. For example
Expand Down Expand Up @@ -268,7 +268,7 @@ configuration of the system.
```sh
# the resulting documentation will appear in a folder named docs in the build
# directory
make docs
cmake --build . --target docs
```


Expand All @@ -279,7 +279,7 @@ tests and display the results. If you're concerned that the build may not work
on your architecture, then this is the best way to verify.

```sh
make check
cmake --build . --target check
```

The `check` target will download and build the Google Test library in the build
Expand All @@ -290,20 +290,22 @@ If you're curious about how the library will perform on your system, use the
will download and build the Google Benchmark library in order to run.

```sh
make bench
cmake --build . --target bench
```


## Installing your Build
You can use the install target to install the library on your machine after the
build.
build. This example uses the cmake `--install` command, but you could also use
the `install` build target for your specific build system, for example
`make install` in a GNU make build.

```sh
make install
cmake --install .

# if the above doesn't work, you might need sudo to install files into the
# correct system folders
sudo make install
sudo cmake --install .
```

A simple way to make sure that your install is working as you expected is to
Expand All @@ -313,7 +315,7 @@ your install.

```sh
# first we use the build target to make sure it works
make example-entry && ./example-entry
cmake --build . --target run-example-entry

# next, we compile the same example manually
gcc docs/examples/entry/entry_example.c -lstumpless -omanual_entry_example
Expand All @@ -333,7 +335,8 @@ the environment variable `LIBRARY_PATH` in Cygwin.
If you find that stumpless has installed to unexpected locations and you want
to modify this, use the `CMAKE_INSTALL_PREFIX` definition during the
configuration step of the build. You can always re-run cmake to update this in
an existing build tree if you need to change it.
an existing build tree if you need to change it, or supply the `--prefix` option
to `cmake --install` to change it at install time.

```sh
# our initial build installed to /usr/local locations, which we didn't want
Expand All @@ -345,11 +348,8 @@ cat install_manifest.txt
# /usr/local/include/stumpless.h
# <output truncated>

# re-run the configuration
cmake -DCMAKE_INSTALL_PREFIX=/usr ../stumpless

# re-do the install
sudo make install
# re-do the install with a different prefix
sudo cmake --install . --prefix /usr

# now we see things in the right place!
cat install_manifest.txt
Expand Down Expand Up @@ -401,14 +401,14 @@ testing the C++ library can be done like this:
# this will emit a warning and leave c++ disabled if wrapture cannot be found
cmake -DENABLE_CPP=ON ../stumpless

# the all target will now include the stumpless c++ library
make all
# the default target will now include the stumpless c++ library
cmake --build .

# to test the library, use the `check-cpp` target
make check-cpp
cmake --build . --target check-cpp

# when enabled, the C++ bindings are installed along with the library itself
# so the following command will install the c++ headers and library in addition
# to the c headers and library
make install
cmake --install .
```
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-v2.1-ff69b4.svg)](https://github.com/goatshriek/stumpless/blob/latest/docs/CODE_OF_CONDUCT.md)


[简体中文](./l10n/zh-cn/自述.md)
[한국어](./l10n/ko-kr/README.md) | [简体中文](./l10n/zh-cn/自述.md)


[Key Features](#key-features) |
Expand All @@ -33,7 +33,7 @@ Stumpless has lots of features that make logging in C fast and easy:
🇯🇵 🇰🇪 🇰🇷 🇵🇱 🇸🇰 🇱🇰 🇸🇪 🇹🇷 🇺🇸
([add yours!](https://github.com/goatshriek/stumpless/blob/latest/docs/localization.md))
* easy-access
[documentation](https://goatshriek.github.io/stumpless/docs/c/latest/index.html),
[documentation](https://goatshriek.github.io/stumpless/docs/c/latest/),
[examples](https://github.com/goatshriek/stumpless/tree/latest/docs/examples),
and [support](https://gitter.im/stumpless/community).

Expand All @@ -60,8 +60,7 @@ with your request and we'll work it into our

## Quick Build and Install
Stumpless only requires cmake and a cmake-supported build toolchain (like GCC
or Visual Studio) to build. For a system using the standard GNU make toolchain,
you can simply do:
or Visual Studio) to build.

```sh
# cloning the latest version of the source tree
Expand All @@ -75,10 +74,10 @@ cd build
cmake ../stumpless

# building stumpless (with 4 threads - adjust as desired)
make -j 4 all
cmake --build . --parallel 4

# install the library (you probably need sudo to do this)
sudo make install
sudo cmake --install .
```

Check out the [Installation Instructions](INSTALL.md) for more detail on
Expand Down
15 changes: 15 additions & 0 deletions docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,21 @@ forever if something gets closed! We just want to keep our active work nice
and tidy for everyone to quickly see what we're doing (and what we aren't).


## A note on AI
Contributions to this project are judged primarily on quality. You are free to
use whatever tools you like including LLMs or some other generative AI, of
course provided that you have enough ownership over the result to contribute it
freely.

However if you use AI to generate a pull request, issue, or discussion response
of low quality, it will be the same as if you submitted low-quality work that
you made yourself. That is, the maintainers may begin to go through the
[enforcement guidelines](https://github.com/goatshriek/stumpless/blob/latest/docs/CODE_OF_CONDUCT.md#enforcement-guidelines)
of the Code of Conduct to correct the behavior. Be considerate of everyone's
time and take the time to review your work and interactions before submitting,
and you are unlikely to run into problems.


## Thanks!
And no matter how you contribute, thanks for giving back to the community!

Expand Down
25 changes: 12 additions & 13 deletions docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ Stumpless is configured using the popular [CMake](https://cmake.org/) build
platform. In order to build it from the source you will need this tool
available, as well as any of a number of supported build systems.
[GNU Make](https://www.gnu.org/software/make/) is one of the most well-known
ones, and so most if not all examples you will find in stumpless
documentation use it. If you prefer to use something else, there is plenty of
support for CMake in other build systems. For example, Visual Studio has CMake
support built in so that you can build targets in a CMake project easily within
the IDE itself.
ones, and many examples you will find online use it. If you prefer to use
something else, there is plenty of support for CMake in other build systems.
For example, Visual Studio has CMake support built in so that you can build
targets in a CMake project easily within the IDE itself.

The `CMakeLists.txt` file contains the build specification for stumpless, and is
worth browsing through if you are curious about where configuration checks,
Expand Down Expand Up @@ -179,8 +178,8 @@ First, always make sure that you have documented your function, especially if it
is public facing. Stumpless uses [doxygen](https://www.doxygen.nl/index.html) to
generate its documentation from the header files. You can use the `docs` build
target to generate them, provided that doxygen was installed when you ran cmake.
Be sure to an include an `@since` tag with the current version of the library
under work, so that it is clearn when it was introduced.
Be sure to include an `@since` tag with the current version (the project version
at the top of `CMakeLists.txt`) so that when it was introduced is clear.

As you look at other functions, you will see that each function documents its
thread and async safety attributes in addition to its functionality. There is
Expand Down Expand Up @@ -320,13 +319,13 @@ cmake -DGTEST_PATH=../gtest -DBENCHMARK_PATH=../benchmark ../stumpless

# in this build Google Test and Benchmark will be downloaded and built since
# the paths we provided don't have anything in them
make check
make bench
cmake --build . --target check
cmake --build . --target bench

# to build the libraries and put them in the path for future builds, we just
# execute these two targets:
make export-gtest
make export-benchmark
cmake --build . --target export-gtest
cmake --build . --target export-benchmark

# these list commands show that the folders are now populated!
ls ../gtest
Expand All @@ -349,8 +348,8 @@ cmake -DGTEST_PATH=../gtest -DBENCHMARK_PATH=../benchmark ../stumpless
# running the test suite or benchmark suite won't download the libraries this
# time - it will go straight to compiling the tests and linking them against
# the libraries in the PATH variables
make check
make bench
cmake --build . --target check
cmake --build . --target bench
```


Expand Down
2 changes: 1 addition & 1 deletion docs/portability.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ certain target types are support is also available, for example if the
`STUMPLESS_SOCKET_TARGETS_SUPPORTED` symbol is defined, then Unix sockets are
available in this build. A complete list of the symbols in this header can be
found in the
[documentation](https://goatshriek.github.io/stumpless/docs/c/latest/config_8h.html).
[documentation](https://goatshriek.github.io/stumpless/docs/c/latest/).

However, this header does not include information needed to make some internal
code decisions. For example, the public header will not indicate whether a
Expand Down
3 changes: 3 additions & 0 deletions include/private/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
#cmakedefine HAVE_VSNPRINTF_S 1
#cmakedefine HAVE_WCSRTOMBS_S 1
#cmakedefine HAVE_WCSTOMBS_S 1
#cmakedefine HAVE_SO_NOSIGPIPE 1
#cmakedefine HAVE_MSG_NOSIGNAL 1


/* function support checks */
#cmakedefine SUPPORT_ABSTRACT_SOCKET_NAMES 1
Expand Down
7 changes: 7 additions & 0 deletions include/private/config/have_sys_socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,15 @@
# define __STUMPLESS_PRIVATE_CONFIG_HAVE_SYS_SOCKET_H

# include <stddef.h>
# include <sys/socket.h>
# include "private/target/network.h"

# ifdef HAVE_SO_NOSIGPIPE
# define config_disallow_signal_during_sending_flag SO_NOSIGPIPE
# elif defined(HAVE_MSG_NOSIGNAL)
# define config_disallow_signal_during_sending_flag MSG_NOSIGNAL
# endif

void
sys_socket_close_network_target( const struct network_target *target );

Expand Down
5 changes: 5 additions & 0 deletions include/private/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,11 @@ size_t get_paged_size( size_t size );
* allocation failure error.
*/
void *realloc_mem( const void *mem, size_t size );

// A wrapper for alloc_mem that checks for overflow before proper allocation
void *alloc_array( size_t item_count, size_t item_size );

// A wrapper for realloc_mem that checks for overflow before proper allocation
void *realloc_array( const void *mem, size_t item_count, size_t item_size );

#endif /* __STUMPLESS_PRIVATE_MEMORY_H */
Loading

0 comments on commit cd2c7ac

Please sign in to comment.