Skip to content

Commit

Permalink
llama.cpp: add logging example/exploration code
Browse files Browse the repository at this point in the history
  • Loading branch information
danbev committed Oct 30, 2024
1 parent e297d8b commit 402d9eb
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
6 changes: 6 additions & 0 deletions fundamentals/llama.cpp/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ batch: src/batch.cpp
embeddings: src/embeddings.cpp
$(CXX) $(CXXFLAGS) $^ -o $@ $(OBJ_GGML) $(OBJ) $(OBJ_COMMON) $(LIBS)

logging: src/logging.cpp
$(CXX) $(CXXFLAGS) $^ -o $@ $(OBJ_GGML) $(OBJ) $(OBJ_COMMON) $(LIBS)

logging-pre: src/logging.cpp
$(CXX) $(CXXFLAGS) -E $^

run-simple-prompt: simple-prompt
./simple-prompt

Expand Down
26 changes: 26 additions & 0 deletions fundamentals/llama.cpp/src/logging.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include "log.h"
#include <cstdio>

int main(int argc, char** argv) {
LOG("logging example\n");

// Set log verbosity threshold to 3 (GGML_LOG_LEVEL_ERROR)
common_log_set_verbosity_thold(3);
LOG("\n");

LOG("common_log_set_verbosity_thold: %d \n", common_log_verbosity_thold);
LOG("\n");

LOG_INF("LOG_FIN verbosity does not matter\n");
LOG_ERR("LOG_ERR verbosity does not matter\n");
LOG("\n");

LOG("Log macros with verbosity:\n");
LOG_INFV(GGML_LOG_LEVEL_ERROR, "LOG_INFV verbosity error info\n");
LOG_INFV(GGML_LOG_LEVEL_NONE, "LOG_INFV verbosisty none info\n");
LOG_ERRV(GGML_LOG_LEVEL_ERROR, "LOG_INFV verbosity error error\n");

LOG_ERRV(4, "LOG_ERRV will not be printed if verbosity is 4! \n");

return 0;
}

0 comments on commit 402d9eb

Please sign in to comment.