mirror of
https://github.com/ultravioletrs/cocos.git
synced 2026-06-23 04:10:25 +00:00
NOISSUE - Use constants for log level (#240)
* use constants for log level Signed-off-by: Sammy Oina <sammyoina@gmail.com> * fix tests Signed-off-by: Sammy Oina <sammyoina@gmail.com> --------- Signed-off-by: Sammy Oina <sammyoina@gmail.com>
This commit is contained in:
committed by
GitHub
parent
e26deb98e4
commit
355f95771d
@@ -6,6 +6,7 @@ import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"io"
|
||||
"log/slog"
|
||||
|
||||
"github.com/ultravioletrs/cocos/pkg/manager"
|
||||
"google.golang.org/protobuf/types/known/timestamppb"
|
||||
@@ -62,7 +63,7 @@ func (s *Stdout) Write(p []byte) (n int, err error) {
|
||||
AgentLog: &manager.AgentLog{
|
||||
Message: string(buf[:n]),
|
||||
ComputationId: s.ComputationId,
|
||||
Level: "debug",
|
||||
Level: slog.LevelDebug.String(),
|
||||
Timestamp: timestamppb.Now(),
|
||||
},
|
||||
},
|
||||
@@ -101,7 +102,7 @@ func (s *Stderr) Write(p []byte) (n int, err error) {
|
||||
AgentLog: &manager.AgentLog{
|
||||
Message: string(buf[:n]),
|
||||
ComputationId: s.ComputationId,
|
||||
Level: "error",
|
||||
Level: slog.LevelError.String(),
|
||||
Timestamp: timestamppb.Now(),
|
||||
},
|
||||
},
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
package vm
|
||||
|
||||
import (
|
||||
"log/slog"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -54,7 +55,7 @@ func TestStdoutWrite(t *testing.T) {
|
||||
agentLog := msg.GetAgentLog()
|
||||
assert.NotNil(t, agentLog)
|
||||
assert.Equal(t, "test-computation", agentLog.ComputationId)
|
||||
assert.Equal(t, "debug", agentLog.Level)
|
||||
assert.Equal(t, slog.LevelDebug.String(), agentLog.Level)
|
||||
assert.NotEmpty(t, agentLog.Message)
|
||||
assert.NotNil(t, agentLog.Timestamp)
|
||||
case <-time.After(time.Second):
|
||||
@@ -113,7 +114,7 @@ func TestStderrWrite(t *testing.T) {
|
||||
agentLog := msg.GetAgentLog()
|
||||
assert.NotNil(t, agentLog)
|
||||
assert.Equal(t, "test-computation", agentLog.ComputationId)
|
||||
assert.Equal(t, "error", agentLog.Level)
|
||||
assert.Equal(t, slog.LevelError.String(), agentLog.Level)
|
||||
assert.NotEmpty(t, agentLog.Message)
|
||||
assert.NotNil(t, agentLog.Timestamp)
|
||||
case *manager.ClientStreamMessage_AgentEvent:
|
||||
|
||||
Reference in New Issue
Block a user