Skip to content

Commit

Permalink
improve(logs): allow logs without a message
Browse files Browse the repository at this point in the history
  • Loading branch information
sdnts committed Sep 16, 2023
1 parent 28c139e commit c58d594
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/endpoints/logs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const LogSchema = z.object({
}),

// Text content of the log
message: z.string(),
message: z.string().optional(),

// Metadata specific to this log line
kv: LogKVSchema.optional(),
Expand Down
39 changes: 37 additions & 2 deletions tests/logs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ test("with both kv", async () => {
});
});

test('with undefined kv values', async () => {
test("with undefined kv values", async () => {
const res = await logs
.ship(
{
Expand Down Expand Up @@ -320,7 +320,42 @@ test('with undefined kv values', async () => {
},
],
});
})
});

test("with no message", async () => {
const res = await logs
.ship(
{
success: true,
data: {
service: "blob-city",
environment: "production",
kv: { common: undefined },
logs: [
{
level: "info",
timestamp: { p: "ns", v: "001" },
},
],
},
},
env,
)
.then((r) => r.json());

expect(res).toStrictEqual({
streams: [
{
stream: {
environment: "production",
service: "blob-city",
level: "info",
},
values: [["001", ""]],
},
],
});
});

test("multiple logs", async () => {
const res = await logs
Expand Down

0 comments on commit c58d594

Please sign in to comment.