janhq / cortex.cpp

Local AI API Platform
https://cortex.so
Apache License 2.0
2.11k stars 122 forks source link

epic: Cortex.cpp logs #1153

Closed dan-homebrew closed 2 months ago

dan-homebrew commented 2 months ago

Goal

Open Questions

Tasklist

dan-homebrew commented 2 months ago

@nguyenhoangthuan99 I would like to raise a few issues on the Logs implementation, based on what I saw on Fri's demo:

Issue 1: UDS for combined log file?

Issue 2: Configurable log file?

Issue 3: Logging parameters

cc @vansangpfiev @namchuai @louis-jan thoughts pls

nguyenhoangthuan99 commented 2 months ago

Issue 1: UDS

Issue 2: Configurable logfile:

Issue 3: Logging Params

vansangpfiev commented 2 months ago

I agree

Issue 1: UDS

  • Initially, UDS was planned as the connection method between cortex-js and cortex-cpp, especially when integrating with Jan, cortex-js, and cortex-cpp. However, now that cortex-js development has stopped, this plan can be reconsidered.
  • The idea of having separate log files for the server and CLI is a better solution, which I support. In the past, we opted for a single log file as cortex-js had done, but the new approach offers clearer separation.

Issue 2: Configurable logfile:

  • We will implement configurable log locations.
  • Previously, there was a discussion about separating logs for the CLI, cortex-cpp server, and engines (llamacpp, tensorrt-llm) or merging them into one cortex.log. However, this may no longer be necessary. A single log file should suffice since Jan users generally won’t need multiple logs. Additionally, the log file contains sufficient information, like filenames and line numbers, to identify issues.

Issue 3: Logging Params

  • We decided to use Trantor (a dependency of Drogon) for logging as it provides all the features we need, such as non-blocking, thread safety, and multi-stream file logging, without impacting system performance.
  • Trantor automatically formats logs for each server session, creating a new log file each time the server starts based on the date and timestamp. This makes debugging easier for general usecases. It also supports setting limits on log file size and the number of log files per session.
  • For Jan and cortex-cpp, which will frequently start and stop the server, we need to implement a custom logger based on Trantor's AsyncFileLogger. This logger will be added to work with cortex-cpp, cortex.llamacpp, and cortex.tensorrt-llm, need to make change to engines repos too. cc @vansangpfiev

I agree. Just want to confirm that we will add the log configuration into .cortexrc, right?

namchuai commented 2 months ago

I also agree, just have some thoughts.

dan-homebrew commented 2 months ago

I also agree, just have some thoughts.

  • Even if we separate the log file (server and cli), there is still chances that log can't be write, e.g. when user spawning multiple terminal and some operation takes long time to finish.
  • Separating log is harder to trace the issue. We might need to chronologically read between two log files to understand the issue.

For logs, do we have a standard Trantor line format (e.g. TIME Log message)?