Skip to content

Commit

Permalink
Some logging fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
DanG100 committed Sep 12, 2024
1 parent 6627c8d commit 82cc6de
Show file tree
Hide file tree
Showing 50 changed files with 1,330 additions and 902 deletions.
28 changes: 14 additions & 14 deletions dataplane/apigen/ccgen/ccgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -824,9 +824,9 @@ return msg;
if (!status.ok()) {
auto it = context.GetServerTrailingMetadata().find("traceparent");
if (it != context.GetServerTrailingMetadata().end()) {
LOG(ERROR) << "Trace ID " << it->second << " " << status.error_message();
LOG(ERROR) << "Lucius RPC error: Trace ID " << it->second << " msg: " << status.error_message();
} else {
LOG(ERROR) << status.error_message();
LOG(ERROR) << "Lucius RPC error: " << status.error_message();
}
return SAI_STATUS_FAILURE;
}
Expand Down Expand Up @@ -856,9 +856,9 @@ return msg;
if (!status.ok()) {
auto it = context.GetServerTrailingMetadata().find("traceparent");
if (it != context.GetServerTrailingMetadata().end()) {
LOG(ERROR) << "Trace ID " << it->second << " " << status.error_message();
LOG(ERROR) << "Lucius RPC error: Trace ID " << it->second << " msg: " << status.error_message();
} else {
LOG(ERROR) << status.error_message();
LOG(ERROR) << "Lucius RPC error: " << status.error_message();
}
return SAI_STATUS_FAILURE;
}
Expand All @@ -884,9 +884,9 @@ return msg;
if (!status.ok()) {
auto it = context.GetServerTrailingMetadata().find("traceparent");
if (it != context.GetServerTrailingMetadata().end()) {
LOG(ERROR) << "Trace ID " << it->second << " " << status.error_message();
LOG(ERROR) << "Lucius RPC error: Trace ID " << it->second << " msg: " << status.error_message();
} else {
LOG(ERROR) << status.error_message();
LOG(ERROR) << "Lucius RPC error: " << status.error_message();
}
return SAI_STATUS_FAILURE;
}
Expand All @@ -906,9 +906,9 @@ return msg;
if (!status.ok()) {
auto it = context.GetServerTrailingMetadata().find("traceparent");
if (it != context.GetServerTrailingMetadata().end()) {
LOG(ERROR) << "Trace ID " << it->second << " " << status.error_message();
LOG(ERROR) << "Lucius RPC error: Trace ID " << it->second << " msg: " << status.error_message();
} else {
LOG(ERROR) << status.error_message();
LOG(ERROR) << "Lucius RPC error: " << status.error_message();
}
return SAI_STATUS_FAILURE;
}
Expand All @@ -922,9 +922,9 @@ return msg;
if (!status.ok()) {
auto it = context.GetServerTrailingMetadata().find("traceparent");
if (it != context.GetServerTrailingMetadata().end()) {
LOG(ERROR) << "Trace ID " << it->second << " " << status.error_message();
LOG(ERROR) << "Lucius RPC error: Trace ID " << it->second << " msg: " << status.error_message();
} else {
LOG(ERROR) << status.error_message();
LOG(ERROR) << "Lucius RPC error: " << status.error_message();
}
return SAI_STATUS_FAILURE;
}
Expand All @@ -942,9 +942,9 @@ return msg;
if (!status.ok()) {
auto it = context.GetServerTrailingMetadata().find("traceparent");
if (it != context.GetServerTrailingMetadata().end()) {
LOG(ERROR) << "Trace ID " << it->second << " " << status.error_message();
LOG(ERROR) << "Lucius RPC error: Trace ID " << it->second << " msg: " << status.error_message();
} else {
LOG(ERROR) << status.error_message();
LOG(ERROR) << "Lucius RPC error: " << status.error_message();
}
return SAI_STATUS_FAILURE;
}
Expand All @@ -967,9 +967,9 @@ return msg;
if (!status.ok()) {
auto it = context.GetServerTrailingMetadata().find("traceparent");
if (it != context.GetServerTrailingMetadata().end()) {
LOG(ERROR) << "Trace ID " << it->second << " " << status.error_message();
LOG(ERROR) << "Lucius RPC error: Trace ID " << it->second << " msg: " << status.error_message();
} else {
LOG(ERROR) << status.error_message();
LOG(ERROR) << "Lucius RPC error: " << status.error_message();
}
return SAI_STATUS_FAILURE;
}
Expand Down
14 changes: 2 additions & 12 deletions dataplane/standalone/lucius/lucius.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,8 @@ func main() {
}

func getLogger() logging.Logger {
return logging.LoggerFunc(func(ctx context.Context, level logging.Level, msg string, fields ...any) {
switch level {
case logging.LevelDebug:
slog.DebugContext(ctx, msg, fields)
case logging.LevelInfo:
slog.InfoContext(ctx, msg, fields)
case logging.LevelWarn:
slog.WarnContext(ctx, msg, fields)
case logging.LevelError:
slog.ErrorContext(ctx, msg, fields)
}
return logging.LoggerFunc(func(ctx context.Context, lvl logging.Level, msg string, fields ...any) {
slog.Log(ctx, slog.Level(lvl), msg, fields...)
})
}

Expand Down Expand Up @@ -151,7 +142,6 @@ func setupOTelSDK(ctx context.Context) (func(context.Context) error, error) {
)

meterProvider := sdkmetric.NewMeterProvider(
sdkmetric.WithReader(sdkmetric.NewPeriodicReader(nil)),
sdkmetric.WithResource(res),
)

Expand Down
100 changes: 60 additions & 40 deletions dataplane/standalone/sai/acl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -882,9 +882,10 @@ sai_status_t l_create_acl_table(sai_object_id_t *acl_table_id,
if (!status.ok()) {
auto it = context.GetServerTrailingMetadata().find("traceparent");
if (it != context.GetServerTrailingMetadata().end()) {
LOG(ERROR) << "Trace ID " << it->second << " " << status.error_message();
LOG(ERROR) << "Lucius RPC error: Trace ID " << it->second
<< " msg: " << status.error_message();
} else {
LOG(ERROR) << status.error_message();
LOG(ERROR) << "Lucius RPC error: " << status.error_message();
}
return SAI_STATUS_FAILURE;
}
Expand All @@ -907,9 +908,10 @@ sai_status_t l_remove_acl_table(sai_object_id_t acl_table_id) {
if (!status.ok()) {
auto it = context.GetServerTrailingMetadata().find("traceparent");
if (it != context.GetServerTrailingMetadata().end()) {
LOG(ERROR) << "Trace ID " << it->second << " " << status.error_message();
LOG(ERROR) << "Lucius RPC error: Trace ID " << it->second
<< " msg: " << status.error_message();
} else {
LOG(ERROR) << status.error_message();
LOG(ERROR) << "Lucius RPC error: " << status.error_message();
}
return SAI_STATUS_FAILURE;
}
Expand Down Expand Up @@ -942,9 +944,10 @@ sai_status_t l_get_acl_table_attribute(sai_object_id_t acl_table_id,
if (!status.ok()) {
auto it = context.GetServerTrailingMetadata().find("traceparent");
if (it != context.GetServerTrailingMetadata().end()) {
LOG(ERROR) << "Trace ID " << it->second << " " << status.error_message();
LOG(ERROR) << "Lucius RPC error: Trace ID " << it->second
<< " msg: " << status.error_message();
} else {
LOG(ERROR) << status.error_message();
LOG(ERROR) << "Lucius RPC error: " << status.error_message();
}
return SAI_STATUS_FAILURE;
}
Expand Down Expand Up @@ -1283,9 +1286,10 @@ sai_status_t l_create_acl_entry(sai_object_id_t *acl_entry_id,
if (!status.ok()) {
auto it = context.GetServerTrailingMetadata().find("traceparent");
if (it != context.GetServerTrailingMetadata().end()) {
LOG(ERROR) << "Trace ID " << it->second << " " << status.error_message();
LOG(ERROR) << "Lucius RPC error: Trace ID " << it->second
<< " msg: " << status.error_message();
} else {
LOG(ERROR) << status.error_message();
LOG(ERROR) << "Lucius RPC error: " << status.error_message();
}
return SAI_STATUS_FAILURE;
}
Expand All @@ -1308,9 +1312,10 @@ sai_status_t l_remove_acl_entry(sai_object_id_t acl_entry_id) {
if (!status.ok()) {
auto it = context.GetServerTrailingMetadata().find("traceparent");
if (it != context.GetServerTrailingMetadata().end()) {
LOG(ERROR) << "Trace ID " << it->second << " " << status.error_message();
LOG(ERROR) << "Lucius RPC error: Trace ID " << it->second
<< " msg: " << status.error_message();
} else {
LOG(ERROR) << status.error_message();
LOG(ERROR) << "Lucius RPC error: " << status.error_message();
}
return SAI_STATUS_FAILURE;
}
Expand Down Expand Up @@ -1716,9 +1721,10 @@ sai_status_t l_set_acl_entry_attribute(sai_object_id_t acl_entry_id,
if (!status.ok()) {
auto it = context.GetServerTrailingMetadata().find("traceparent");
if (it != context.GetServerTrailingMetadata().end()) {
LOG(ERROR) << "Trace ID " << it->second << " " << status.error_message();
LOG(ERROR) << "Lucius RPC error: Trace ID " << it->second
<< " msg: " << status.error_message();
} else {
LOG(ERROR) << status.error_message();
LOG(ERROR) << "Lucius RPC error: " << status.error_message();
}
return SAI_STATUS_FAILURE;
}
Expand All @@ -1744,9 +1750,10 @@ sai_status_t l_get_acl_entry_attribute(sai_object_id_t acl_entry_id,
if (!status.ok()) {
auto it = context.GetServerTrailingMetadata().find("traceparent");
if (it != context.GetServerTrailingMetadata().end()) {
LOG(ERROR) << "Trace ID " << it->second << " " << status.error_message();
LOG(ERROR) << "Lucius RPC error: Trace ID " << it->second
<< " msg: " << status.error_message();
} else {
LOG(ERROR) << status.error_message();
LOG(ERROR) << "Lucius RPC error: " << status.error_message();
}
return SAI_STATUS_FAILURE;
}
Expand Down Expand Up @@ -2217,9 +2224,10 @@ sai_status_t l_create_acl_counter(sai_object_id_t *acl_counter_id,
if (!status.ok()) {
auto it = context.GetServerTrailingMetadata().find("traceparent");
if (it != context.GetServerTrailingMetadata().end()) {
LOG(ERROR) << "Trace ID " << it->second << " " << status.error_message();
LOG(ERROR) << "Lucius RPC error: Trace ID " << it->second
<< " msg: " << status.error_message();
} else {
LOG(ERROR) << status.error_message();
LOG(ERROR) << "Lucius RPC error: " << status.error_message();
}
return SAI_STATUS_FAILURE;
}
Expand All @@ -2242,9 +2250,10 @@ sai_status_t l_remove_acl_counter(sai_object_id_t acl_counter_id) {
if (!status.ok()) {
auto it = context.GetServerTrailingMetadata().find("traceparent");
if (it != context.GetServerTrailingMetadata().end()) {
LOG(ERROR) << "Trace ID " << it->second << " " << status.error_message();
LOG(ERROR) << "Lucius RPC error: Trace ID " << it->second
<< " msg: " << status.error_message();
} else {
LOG(ERROR) << status.error_message();
LOG(ERROR) << "Lucius RPC error: " << status.error_message();
}
return SAI_STATUS_FAILURE;
}
Expand Down Expand Up @@ -2277,9 +2286,10 @@ sai_status_t l_set_acl_counter_attribute(sai_object_id_t acl_counter_id,
if (!status.ok()) {
auto it = context.GetServerTrailingMetadata().find("traceparent");
if (it != context.GetServerTrailingMetadata().end()) {
LOG(ERROR) << "Trace ID " << it->second << " " << status.error_message();
LOG(ERROR) << "Lucius RPC error: Trace ID " << it->second
<< " msg: " << status.error_message();
} else {
LOG(ERROR) << status.error_message();
LOG(ERROR) << "Lucius RPC error: " << status.error_message();
}
return SAI_STATUS_FAILURE;
}
Expand All @@ -2305,9 +2315,10 @@ sai_status_t l_get_acl_counter_attribute(sai_object_id_t acl_counter_id,
if (!status.ok()) {
auto it = context.GetServerTrailingMetadata().find("traceparent");
if (it != context.GetServerTrailingMetadata().end()) {
LOG(ERROR) << "Trace ID " << it->second << " " << status.error_message();
LOG(ERROR) << "Lucius RPC error: Trace ID " << it->second
<< " msg: " << status.error_message();
} else {
LOG(ERROR) << status.error_message();
LOG(ERROR) << "Lucius RPC error: " << status.error_message();
}
return SAI_STATUS_FAILURE;
}
Expand Down Expand Up @@ -2352,9 +2363,10 @@ sai_status_t l_create_acl_range(sai_object_id_t *acl_range_id,
if (!status.ok()) {
auto it = context.GetServerTrailingMetadata().find("traceparent");
if (it != context.GetServerTrailingMetadata().end()) {
LOG(ERROR) << "Trace ID " << it->second << " " << status.error_message();
LOG(ERROR) << "Lucius RPC error: Trace ID " << it->second
<< " msg: " << status.error_message();
} else {
LOG(ERROR) << status.error_message();
LOG(ERROR) << "Lucius RPC error: " << status.error_message();
}
return SAI_STATUS_FAILURE;
}
Expand All @@ -2377,9 +2389,10 @@ sai_status_t l_remove_acl_range(sai_object_id_t acl_range_id) {
if (!status.ok()) {
auto it = context.GetServerTrailingMetadata().find("traceparent");
if (it != context.GetServerTrailingMetadata().end()) {
LOG(ERROR) << "Trace ID " << it->second << " " << status.error_message();
LOG(ERROR) << "Lucius RPC error: Trace ID " << it->second
<< " msg: " << status.error_message();
} else {
LOG(ERROR) << status.error_message();
LOG(ERROR) << "Lucius RPC error: " << status.error_message();
}
return SAI_STATUS_FAILURE;
}
Expand Down Expand Up @@ -2412,9 +2425,10 @@ sai_status_t l_get_acl_range_attribute(sai_object_id_t acl_range_id,
if (!status.ok()) {
auto it = context.GetServerTrailingMetadata().find("traceparent");
if (it != context.GetServerTrailingMetadata().end()) {
LOG(ERROR) << "Trace ID " << it->second << " " << status.error_message();
LOG(ERROR) << "Lucius RPC error: Trace ID " << it->second
<< " msg: " << status.error_message();
} else {
LOG(ERROR) << status.error_message();
LOG(ERROR) << "Lucius RPC error: " << status.error_message();
}
return SAI_STATUS_FAILURE;
}
Expand Down Expand Up @@ -2446,9 +2460,10 @@ sai_status_t l_create_acl_table_group(sai_object_id_t *acl_table_group_id,
if (!status.ok()) {
auto it = context.GetServerTrailingMetadata().find("traceparent");
if (it != context.GetServerTrailingMetadata().end()) {
LOG(ERROR) << "Trace ID " << it->second << " " << status.error_message();
LOG(ERROR) << "Lucius RPC error: Trace ID " << it->second
<< " msg: " << status.error_message();
} else {
LOG(ERROR) << status.error_message();
LOG(ERROR) << "Lucius RPC error: " << status.error_message();
}
return SAI_STATUS_FAILURE;
}
Expand All @@ -2471,9 +2486,10 @@ sai_status_t l_remove_acl_table_group(sai_object_id_t acl_table_group_id) {
if (!status.ok()) {
auto it = context.GetServerTrailingMetadata().find("traceparent");
if (it != context.GetServerTrailingMetadata().end()) {
LOG(ERROR) << "Trace ID " << it->second << " " << status.error_message();
LOG(ERROR) << "Lucius RPC error: Trace ID " << it->second
<< " msg: " << status.error_message();
} else {
LOG(ERROR) << status.error_message();
LOG(ERROR) << "Lucius RPC error: " << status.error_message();
}
return SAI_STATUS_FAILURE;
}
Expand Down Expand Up @@ -2507,9 +2523,10 @@ sai_status_t l_get_acl_table_group_attribute(sai_object_id_t acl_table_group_id,
if (!status.ok()) {
auto it = context.GetServerTrailingMetadata().find("traceparent");
if (it != context.GetServerTrailingMetadata().end()) {
LOG(ERROR) << "Trace ID " << it->second << " " << status.error_message();
LOG(ERROR) << "Lucius RPC error: Trace ID " << it->second
<< " msg: " << status.error_message();
} else {
LOG(ERROR) << status.error_message();
LOG(ERROR) << "Lucius RPC error: " << status.error_message();
}
return SAI_STATUS_FAILURE;
}
Expand Down Expand Up @@ -2554,9 +2571,10 @@ sai_status_t l_create_acl_table_group_member(
if (!status.ok()) {
auto it = context.GetServerTrailingMetadata().find("traceparent");
if (it != context.GetServerTrailingMetadata().end()) {
LOG(ERROR) << "Trace ID " << it->second << " " << status.error_message();
LOG(ERROR) << "Lucius RPC error: Trace ID " << it->second
<< " msg: " << status.error_message();
} else {
LOG(ERROR) << status.error_message();
LOG(ERROR) << "Lucius RPC error: " << status.error_message();
}
return SAI_STATUS_FAILURE;
}
Expand All @@ -2580,9 +2598,10 @@ sai_status_t l_remove_acl_table_group_member(
if (!status.ok()) {
auto it = context.GetServerTrailingMetadata().find("traceparent");
if (it != context.GetServerTrailingMetadata().end()) {
LOG(ERROR) << "Trace ID " << it->second << " " << status.error_message();
LOG(ERROR) << "Lucius RPC error: Trace ID " << it->second
<< " msg: " << status.error_message();
} else {
LOG(ERROR) << status.error_message();
LOG(ERROR) << "Lucius RPC error: " << status.error_message();
}
return SAI_STATUS_FAILURE;
}
Expand Down Expand Up @@ -2617,9 +2636,10 @@ sai_status_t l_get_acl_table_group_member_attribute(
if (!status.ok()) {
auto it = context.GetServerTrailingMetadata().find("traceparent");
if (it != context.GetServerTrailingMetadata().end()) {
LOG(ERROR) << "Trace ID " << it->second << " " << status.error_message();
LOG(ERROR) << "Lucius RPC error: Trace ID " << it->second
<< " msg: " << status.error_message();
} else {
LOG(ERROR) << status.error_message();
LOG(ERROR) << "Lucius RPC error: " << status.error_message();
}
return SAI_STATUS_FAILURE;
}
Expand Down
Loading

0 comments on commit 82cc6de

Please sign in to comment.