EJoyer.SDK.Log
1.0.0
dotnet add package EJoyer.SDK.Log --version 1.0.0
NuGet\Install-Package EJoyer.SDK.Log -Version 1.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="EJoyer.SDK.Log" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="EJoyer.SDK.Log" Version="1.0.0" />
<PackageReference Include="EJoyer.SDK.Log" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add EJoyer.SDK.Log --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: EJoyer.SDK.Log, 1.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package EJoyer.SDK.Log@1.0.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=EJoyer.SDK.Log&version=1.0.0
#tool nuget:?package=EJoyer.SDK.Log&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
EJoyer.SDK.Log
项目概述
EJoyer.SDK.Log 是 EJoyer 平台的日志服务 SDK,封装了与日志服务 API 的交互逻辑。该 SDK 基于 IHttpClientFactory 构建高效的 HTTP 通信,提供账户日志、OEM日志、订单日志和货运日志的创建与查询功能。
核心功能
| 功能 | 说明 |
|---|---|
| 订单日志 | 创建订单日志、按订单号查询、批量订单号查询、关键词搜索 |
| 货运日志 | 创建货运日志、按货运密钥查询货运日志列表 |
快速开始
1. 安装 NuGet 包
dotnet add package EJoyer.SDK.Log
2. 注册服务
在 Program.cs 或 Startup.cs 中注册日志服务:
using EJoyer.SDK.Log;
var builder = WebApplication.CreateBuilder(args);
// 注册日志服务客户端
builder.Services.EJoyerLogService();
var app = builder.Build();
app.Run();
3. 使用示例
public class MyService
{
private readonly ILogClient _logClient;
public MyService(ILogClient logClient)
{
_logClient = logClient;
}
public async Task CreateLogAsync()
{
// 创建订单日志
var result = await _logClient.CreateOrderLogAsync(
apiToken: "your-api-token",
orderNumber: "12345-6789012345678",
message: "订单已创建",
operation: "Create"
);
if (result.Success)
{
// 操作成功
}
}
public async Task QueryLogsAsync()
{
// 查询订单日志
var result = await _logClient.GetOrderLogsAsync(
apiToken: "your-api-token",
orderNumber: "12345-6789012345678"
);
if (result.Success && result.Data is not null)
{
foreach (var log in result.Data)
{
Console.WriteLine($"{log.CreateUTCTime}: {log.Message}");
}
}
}
}
统一响应格式
所有接口均返回 APIResponse<T> 类型,继承自 BaseResponse:
| 字段 | 类型 | 说明 |
|---|---|---|
Success |
bool |
操作是否成功 |
Message |
string |
中文消息 |
EMMessage |
string |
英文消息 |
MessageCode |
int |
消息代码(成功为 0,失败为 -1) |
Data |
T? |
响应数据 |
ExecuteMilliseconds |
long |
执行耗时(毫秒) |
注意事项
- API 令牌:所有接口调用均需传入
apiToken参数,令牌通过 HTTP 请求头APIToken传递至服务端。 - 参数校验:SDK 内部对所有必填参数进行了前置校验,若参数为空会立即返回错误响应,不会发起 HTTP 请求。
- 异常处理:SDK 捕获了
HttpRequestException及通用Exception,异常信息通过APIResponse.Message返回,不会抛出至调用方。 - HttpClient 管理:使用
IHttpClientFactory管理连接池,避免 Socket 耗尽问题,请勿手动创建HttpClient。 - 服务注册:通过
services.EJoyerLogService()扩展方法完成注册,内部注册了名为LogServiceClient的命名 HttpClient。
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- EJoyer.SDK.Common (>= 1.0.1)
- Microsoft.Extensions.Http (>= 10.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 124 | 6/10/2026 |