Skip to content

Commit

Permalink
log-disable and log-enable (#8)
Browse files Browse the repository at this point in the history
Refactor log related items into logs.cpp
Add log_pause & log_resume endpoints
Remove std::cout statements
  • Loading branch information
icppWorld authored Feb 7, 2025
1 parent 4706e0e commit 1a0e701
Show file tree
Hide file tree
Showing 15 changed files with 1,493 additions and 1,247 deletions.
1 change: 1 addition & 0 deletions native/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include "../src/auth.h"
#include "../src/health.h"
#include "../src/logs.h"
#include "../src/model.h"
#include "../src/ready.h"
#include "../src/run.h"
Expand Down
1 change: 1 addition & 0 deletions native/test_canister_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "../src/auth.h"
#include "../src/health.h"
#include "../src/logs.h"
#include "../src/model.h"
#include "../src/ready.h"
#include "../src/run.h"
Expand Down
17 changes: 17 additions & 0 deletions native/test_qwen2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "../src/db_chats.h"
#include "../src/health.h"
#include "../src/logs.h"
#include "../src/max_tokens.h"
#include "../src/model.h"
#include "../src/ready.h"
Expand All @@ -24,6 +25,14 @@ void test_qwen2(MockIC &mockIC) {

bool silent_on_trap = true;

// -----------------------------------------------------------------------------
// Pause logging
// '()' -> '(variant { Ok = record { status_code = 200 : nat16; } })'
mockIC.run_test(std::string(__func__) + ": " + "log_pause", log_pause,
"4449444c0000",
"4449444c026c019aa1b2f90c7a6b01bc8a0100010100c800",
silent_on_trap, my_principal);

// -----------------------------------------------------------------------------
// TinyStories models: text generation following a prompt
std::string model =
Expand Down Expand Up @@ -172,4 +181,12 @@ void test_qwen2(MockIC &mockIC) {
"4449444c026c01dd9ad28304016d710100020a2d2d6c6f672d66696c65086d61696e2e6c6f67",
"4449444c026c06819e846471838fe5800671c897a79907719aa1b2f90c7adb92a2c90d71cdd9e6b30e7e6b01bc8a0100010100275375636365737366756c6c792072656d6f766564206c6f672066696c653a206d61696e2e6c6f670000c8000000",
silent_on_trap, my_principal);

// -----------------------------------------------------------------------------
// Resume logging
// '()' -> '(variant { Ok = record { status_code = 200 : nat16; } })'
mockIC.run_test(std::string(__func__) + ": " + "log_resume", log_resume,
"4449444c0000",
"4449444c026c019aa1b2f90c7a6b01bc8a0100010100c800",
silent_on_trap, my_principal);
}
17 changes: 17 additions & 0 deletions native/test_tiny_stories.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <iostream>

#include "../src/health.h"
#include "../src/logs.h"
#include "../src/max_tokens.h"
#include "../src/model.h"
#include "../src/ready.h"
Expand All @@ -23,6 +24,14 @@ void test_tiny_stories(MockIC &mockIC) {

bool silent_on_trap = true;

// -----------------------------------------------------------------------------
// Pause logging
// '()' -> '(variant { Ok = record { status_code = 200 : nat16; } })'
mockIC.run_test(std::string(__func__) + ": " + "log_pause", log_pause,
"4449444c0000",
"4449444c026c019aa1b2f90c7a6b01bc8a0100010100c800",
silent_on_trap, my_principal);

// -----------------------------------------------------------------------------
// TinyStories models: text generation following a prompt
std::vector<std::string> models = {"models/stories260Ktok512.gguf",
Expand Down Expand Up @@ -192,4 +201,12 @@ void test_tiny_stories(MockIC &mockIC) {
silent_on_trap, my_principal);
}
}

// -----------------------------------------------------------------------------
// Resume logging
// '()' -> '(variant { Ok = record { status_code = 200 : nat16; } })'
mockIC.run_test(std::string(__func__) + ": " + "log_resume", log_resume,
"4449444c0000",
"4449444c026c019aa1b2f90c7a6b01bc8a0100010100c800",
silent_on_trap, my_principal);
}
Loading

0 comments on commit 1a0e701

Please sign in to comment.