https://github.com/iammoltony/libmtnlog
Moltony's logging library
https://github.com/iammoltony/libmtnlog
c c-library cross-platform library logging
Last synced: 11 months ago
JSON representation
Moltony's logging library
- Host: GitHub
- URL: https://github.com/iammoltony/libmtnlog
- Owner: IAmMoltony
- License: mit
- Created: 2023-10-25T06:59:55.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-04-13T13:25:06.000Z (almost 2 years ago)
- Last Synced: 2024-04-14T04:05:18.087Z (almost 2 years ago)
- Topics: c, c-library, cross-platform, library, logging
- Language: C
- Homepage: https://iammoltony.github.io/mtnlog/index.html
- Size: 147 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# MtnLog
[](https://www.codefactor.io/repository/github/iammoltony/libmtnlog)
MtnLog is a really simple logging library. Originally created for [ds-craft](https://github.com/IAmMoltony/ds-craft).
## Notice
This library is not developed anymore. You can still contribute and I'll respond,
but don't expect any major new features.
See `rewrite.md`.
## Using the library
Paste the header and source code of the library into your project somewhere. I
recommend creating a separate folder for it and configuring your build system to
add MtnLog's include files and compile its source files.
## Features
- Logging messages into stdout
- Three log levels: info, warning and error
- Logging with timestamps
- Logging with context (function, file and line)
- Change what log level will be printed to the user
- Logging into a file
- Colored log messages
- Log callback - run any code after logging a message
## Testing
Instead of using fancy testing toolkits, there is instead a script that
utilises every feature of the library and it is checked whether the output
looks about right.
### Running tests
#### Using MSVC
MSVC testing can be done using `dotest-msvc.bat` like this:
`dotest-msvc`
#### Non-MSVC
Non-MSVC tests can be run using the `dotest.sh` script:
`./dotest.sh`
By default the script tests using GCC, but it also supports other compilers. To
see the whole list, you can bring up help: `./dotest.sh help`
Please note that you need `bash` installed on your machine for the script
to work.
### Checking for memory leaks
Checking for memory leaks can be done using `check-memleaks.sh`. The script
requires `valgrind` to be installed on the system.
## Docs
MtnLog uses [Doxygen](https://doxygen.nl) for generating documentation.
All you have to do is install it and run `doxygen` in the repo folder.
## Platform compatibility
The library was tested on the following platforms:
- Linux
- Windows
- Nintendo DS (homebrew using devkitPro)
- Haiku
- BSD (tested on NetBSD)
- Nintendo GBA (homebrew using devkitPro)
However, it should work with other POSIX-compatible OSes and environments,
such as macOS.
On Windows, the library uses the Windows API for colored output. On other
platforms it uses ANSI escape sequences.
Before turning color on, make sure that the terminal supports color. You can
use the `mtnlogCheckColor()` function for that.
## Compiler compatibility
The library is known to work on the following compilers:
- GCC
- Clang
- TCC (TinyCC)
- MinGW
- Intel oneAPI C compiler
- Visual Studio 2010+
## Troubleshooting
### `stdbool.h` not found
MtnLog can work without `stdbool.h`. Define the `MTNLOG_NO_STDBOOL` macro
in your compiler/build system options.
This problem usually happens on really old compilers.