Skip to content
ON THIS PAGE

Kamakazi

The C++ log library

Kamakazi is a library for C++ allowing the use of logs in a simpler and more intuitive way.

Kamakazi exists as a way to easily create logs for your programs and return them through the terminal to be read through stdout.

It is also good for error handling as Kamakazi will end the program before any major issues arise using its "dangerLevel" system from 0-10 (0 being: minor issue just ignore, and 10 being: massive issue end program immediately).

Kamakazi also has a reader for logs Kamakazi Reader written in Rust with ratatui (no there is no plans for a Rust as a supported language for Kamakazi), which can be used by using the command kamakazi.

Installing Kamakazi:

System

  • Linux (or UNIX system).
  • clang++ (to compile the code).
  • cargo (to build Kamakazi Reader)
  • make (automate build and install process).

More information about dependencies can be found in the Using Kamakazi section.

Install Kamakazi from source:

bash
# All distrobutions
git clone https://github.com/Ametrine-cc/Kamakazi.git
cd Kamakazi

# --- Building and installing Kamakazi
sudo make clean # Remove any Kamakazi files that may already exist

make # run the make command to build everything initially then install
sudo make install

# --- To uninstall run the uninstall command instead ---
sudo make uninstall

Using Kamakazi:

When using Kamakazi, the library must be linked during compilation. You can do this in two ways:

In clang++ or g++:

bash
# --- Include the KamakaziLib for compilation ---
clang++ src/PROJECT_NAME -lKamakaziLib -o PROJECT_NAME

The example shows clang++ but can be swapped out interchangeably with g++.

In cmake:

bash
# --- Dependencies ---
find_library(KAMAKAZI_PATH NAMES KamakaziLib)

# --- Check if it was actually found ---
if(NOT KAMAKAZI_PATH)
  message(FATAL_ERROR "KamakaziLib not found! Did you install with 'sudo make install'?")
endif()

target_link_libraries(PROJECT_NAME PRIVATE ${KAMAKAZI_PATH})

Replace "PROJECT_NAME" with your project name. All code presented is drag-and-droppable.

Examples:

Example 1

c++
#include <kamakazi>

// Required: Set global values, can be changed later on
bool Kamakazi_Utils::should_log = true;
bool Kamakazi_Utils::ignore_dangerLevel = false;
bool Kamakazi_Utils::show_dangerLevel = true;

// Main loop
int main() {
    // Call Kamakazi: Normal log : Show Kamakazi version
    kazi_log(__FUNCTION__, kamakazi_version);

    // Call Kamakazi: Major error
    // dangerLevel set at 0, exits program quietly as not a major issue
    kamakazi("NO_WALLPAPER", 0);
    return 0;
}

// Output
// [main] Hello from Kamakazi!
// [main] Kamakazi Version 1.0.0
// [ERROR : 0] | NO_WALLPAPER

Example 2

c++
#include <kamakazi>

// Required: Set global values, can be changed later on
bool Kamakazi_Utils::should_log = true;
bool Kamakazi_Utils::ignore_dangerLevel = false;
bool Kamakazi_Utils::show_dangerLevel = true;

// Main loop
int main() {
    // Call Kamakazi: Normal log : Show Kamakazi version
    kazi_log(__FUNCTION__, kamakazi_version);

    // Call Kamakazi: Major error
    // dangerLevel set at 10, immediately exits program to prevent further issues
    kamakazi("NO_FILESYSTEM", 10);
    return 0;
}

// Output
// [main] Hello from Kamakazi!
// [main] Kamakazi Version 1.0.0
// [ERROR : 10] | NO_FILESYSTEM

If dangerLevel is above or equal to 10, the program crashes for safety. If dangerLevel is 0, it exits quietly. In between these values, the program still outputs the errors to the terminal but does not close.

Kamakazi Reader:

Kamakazi includes a simple reader utility, which can be used by entering kamakazi in your terminal / console. This tool allows you to easily view and navigate log files generated by Kamakazi directly from your terminal. The Kamakazi Reader allows all file types to be read natively.

Installation

Install Kamakazi Reader from source:

bash
# All distrobutions
git clone https://github.com/Ametrine-cc/Kamakazi-Reader.git
cd Kamakazi-Reader

# --- Building and installing Kamakazi Reader
sudo make clean # Remove any Kamakazi Reader files that may already exist

make # run the make command to build everything initially then install
sudo make install

# --- To uninstall run the uninstall command instead ---
sudo make uninstall

Use the Kamakazi Reader

  1. Run from the command line: If you have Kamakazi installed it should already come with Kamakazi Reader, or installing Kamakazi Reader installed from source. A log file (my_log.log) you wish to view, you can start the reader with:

    bash
    kamakazi my_log.log

    If no file is provided, it will default to showing files in the ~/.kamakazi/ directory.

  2. Navigation:

    • Use the Up and Down arrow keys (or k and j) to scroll line by line.
    • Use Page Up and Page Down to scroll a full screen at a time.
    • Press q or Ctrl+c to exit the reader.
    • Press Esc or Backspace to return to the file selection screen.

The Kamakazi Reader provides a convenient way to inspect your logs without needing to open a separate text editor, making debugging and monitoring your applications more efficient.

How to contribute?

We welcome contributions from the community to help improve Kamakazi! Whether it's reporting bugs, suggesting new features, or submitting code changes, your help is valuable.

Reporting Bugs

If you find a bug, please help us by reporting it on the GitHub Issues page. When reporting a bug, please include:

  • A clear and concise description of the bug.
  • Steps to reproduce the behavior.
  • Expected behavior vs. actual behavior.
  • Any error messages or logs.
  • Your operating system and compiler version.

Suggestions

Do you have an idea for a new feature or an improvement to an existing one? We'd love to hear about it! Please open an issue on the GitHub Issues page and:

  • Clearly describe the proposed feature or enhancement.
  • Explain the problem it solves or the use case it addresses.
  • (Optional) Provide any thoughts on how it might be implemented.

Thank you for helping to make Kamakazi better!

Credits:

Extras

Currently Kamakazi only supports C++ but functionality is being worked on for native C support. Languages like Python or Rust currently will never get a official release of Kamakazi (This may change in the future).

License

This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.