44namespace LLama . Native
55{
66 /// <summary>
7- /// Severity level of a log message
7+ /// Severity level of a log message. This enum should always be aligned with
8+ /// the one defined on llama.cpp side at
9+ /// https://github.com/ggerganov/llama.cpp/blob/0eb4e12beebabae46d37b78742f4c5d4dbe52dc1/ggml/include/ggml.h#L559
810 /// </summary>
911 public enum LLamaLogLevel
1012 {
1113 /// <summary>
12- /// Logs that highlight when the current flow of execution is stopped due to a failure.
14+ /// Logs are never written.
15+ /// </summary>
16+ None = 0 ,
17+
18+ /// <summary>
19+ /// Logs that are used for interactive investigation during development.
1320 /// </summary>
14- Error = 2 ,
21+ Debug = 1 ,
22+
23+ /// <summary>
24+ /// Logs that track the general flow of the application.
25+ /// </summary>
26+ Info = 2 ,
1527
1628 /// <summary>
1729 /// Logs that highlight an abnormal or unexpected event in the application flow, but do not otherwise cause the application execution to stop.
1830 /// </summary>
1931 Warning = 3 ,
2032
2133 /// <summary>
22- /// Logs that track the general flow of the application .
34+ /// Logs that highlight when the current flow of execution is stopped due to a failure .
2335 /// </summary>
24- Info = 4 ,
36+ Error = 4 ,
2537
2638 /// <summary>
27- /// Logs that are used for interactive investigation during development .
39+ /// Continue log level is equivalent to None in the way it is used in llama.cpp .
2840 /// </summary>
29- Debug = 5 ,
41+ Continue = 5 ,
3042 }
3143
3244 internal static class LLamaLogLevelExtensions
3345 {
46+ /// <summary>
47+ /// Keeps track of the previous log level to be able to handle the log level <see cref="LLamaLogLevel.Continue"/>.
48+ /// </summary>
49+ [ ThreadStatic ] private static LogLevel _previous ;
50+
3451 public static LogLevel ToLogLevel ( this LLamaLogLevel llama )
3552 {
36- return ( llama ) switch
53+ _previous = llama switch
3754 {
38- LLamaLogLevel . Error => LogLevel . Error ,
39- LLamaLogLevel . Warning => LogLevel . Warning ,
40- LLamaLogLevel . Info => LogLevel . Information ,
55+ LLamaLogLevel . None => LogLevel . None ,
4156 LLamaLogLevel . Debug => LogLevel . Debug ,
57+ LLamaLogLevel . Info => LogLevel . Information ,
58+ LLamaLogLevel . Warning => LogLevel . Warning ,
59+ LLamaLogLevel . Error => LogLevel . Error ,
60+ LLamaLogLevel . Continue => _previous ,
4261 _ => throw new ArgumentOutOfRangeException ( nameof ( llama ) , llama , null )
4362 } ;
63+ return _previous ;
4464 }
4565 }
46- }
66+ }
0 commit comments