Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Jul 4, 2025. It is now read-only.

Spec: Cortex.cpp Logs #1112

freelerobot started this conversation in Architecture Specs
Sep 3, 2024 · 3 comments · 2 replies
Discussion options

Goal:

  • Clear, detailed and configurable (levels, verbosity) logging

Spec:

  • Dependency: Trantor with UDS (multi-process logging)
  • Log levels: trace, info, debug, warning, error, fatal
  • Log format: TBA

Maintenance:

  • Log file rotation: when log file exceeds max size, will roll to new file with the same prefix: .00000.log -> .00001.log.
  • Max log file size: 20 Mb.
  • Log purging: TBA

TBA

  • [TBA] verbose mode

Related

Open Questions:

  • What logging library are we using? Stdlib or 3rd party and why?
  • What log levels are supported?
  • Is logging configurable by user?
  • How do you handle log rotation and file size limits?
  • Are logs formatted consistently? e.g. timestamp, source of issue, message
  • How are we passing through upstream errors, e.g. llamacpp errors
  • Where are logs stored?
  • Is logging threadsafe? Are there multiple processes writing to the same logs?
  • Is there a Cortex command to tail logs?
You must be logged in to vote

Replies: 3 comments 2 replies

Comment options

Log library

  • we are using trantor for logging feature because:
    • It is a Drogon's dependencies, so reuse trantor will save some resources
    • trantor is non-blocking I/O cross-platform, thread safe, async library.
    • Support multi streams logger (can chose to write log to different file, stream, ... )
    • Support log file rotation and set max file size: when log file exceeds max size, will roll to new file with the same prefix: <prefix>.00000.log -> <prefix>.00001.log. Currently max log file size is 20 Mb.
    • Support all needed informations: for example 20240903 06:46:55.974670 UTC 1268127 INFO Request 1727: Inference completed - llama_engine.cc:827, it includes time, timezone, process id, log level, message, source code file and line number
    • Log levels:
      • trace
      • info
      • debug
      • warning
      • error
      • fatal

Configuration
Currently, log files are stored under /path_to_cortex_cpp_binary/logs/ but need to configurable, now we set it as default constant in source code

When this Feature is done, we will read from config to decide where to store log file.

Log upstreams
For upstreams like llama.cpp and tensorrt llm, we have to override log method of those and redirect to right posion as we want, this task is Done for llamacpp and tensorrt llm, refer to this issue

Issues
Trantor is thread safe but it keeps the log file open during the life time of server process. With Linux and MacOS, it works perfectly, but in windows, when a process is holding a file, windows prevents other process to access it. Refer to this Issue

Future features

  • Support tail latest logfile
You must be logged in to vote
2 replies
Comment options

freelerobot Sep 6, 2024
Maintainer Author

  1. Log rotation is fine, but what about purging. Previously, we've experienced cases when logs explode to xx Gb for users.
  • Is there a global log file max
  • Is there a max log expiry date, i.e. is there any use in keeping logs older than x Days/Weeks or Months
  1. How do we denote where the log originated, i.e. llamacpp vs cortex.cpp process?
  2. Does CLI have verbose / regular logging modes?
Comment options

freelerobot Sep 6, 2024
Maintainer Author

Also naming wise Im wondering if you should go with - instead of incremental ints

Comment options

  1. Trantor provide methods to set max number of log file under log folder, Trantor will delete the oldest log file first when the maximum files exceed, but we need to experiment to confirm how it exactly works.
  2. Trantor doesn't support this feature.
  3. For now we are using the same log file to log everything (this is configurable), in the log file also contain the file name and line number, -> we can easily find the root cause.
  4. CLI has --verbose flag, when this flag is provided, everything will log to terminal instead of files
  5. For naming format the full structure of log file is .-.0000.log
    Future change
    When this Pr fix: correct path to work with data folder structure #1132 is finished, will move log folder to the data folder (currently, log folder in the same location with binary)
You must be logged in to vote
0 replies
Comment options

Do we log the underlying API requests, e.g. re obj, response
#1007

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: app shell Installer, updaters, distributions
Converted from issue

This discussion was converted from issue #1084 on September 05, 2024 14:09.

AltStyle によって変換されたページ (->オリジナル) /