mirror of
https://github.com/oven-sh/setup-bun.git
synced 2025-07-19 04:58:25 +02:00
feat: add @actions/cache
This commit is contained in:
parent
b15fb7d098
commit
16e8c96a41
1932 changed files with 261172 additions and 10 deletions
47
node_modules/@azure/ms-rest-js/lib/policies/logPolicy.ts
generated
vendored
Normal file
47
node_modules/@azure/ms-rest-js/lib/policies/logPolicy.ts
generated
vendored
Normal file
|
@ -0,0 +1,47 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
|
||||
import { HttpOperationResponse } from "../httpOperationResponse";
|
||||
import { WebResourceLike } from "../webResource";
|
||||
import {
|
||||
BaseRequestPolicy,
|
||||
RequestPolicy,
|
||||
RequestPolicyFactory,
|
||||
RequestPolicyOptionsLike,
|
||||
} from "./requestPolicy";
|
||||
|
||||
export function logPolicy(logger: any = console.log): RequestPolicyFactory {
|
||||
return {
|
||||
create: (nextPolicy: RequestPolicy, options: RequestPolicyOptionsLike) => {
|
||||
return new LogPolicy(nextPolicy, options, logger);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export class LogPolicy extends BaseRequestPolicy {
|
||||
logger?: any;
|
||||
|
||||
constructor(
|
||||
nextPolicy: RequestPolicy,
|
||||
options: RequestPolicyOptionsLike,
|
||||
logger: any = console.log
|
||||
) {
|
||||
super(nextPolicy, options);
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
public sendRequest(request: WebResourceLike): Promise<HttpOperationResponse> {
|
||||
return this._nextPolicy.sendRequest(request).then((response) => logResponse(this, response));
|
||||
}
|
||||
}
|
||||
|
||||
function logResponse(
|
||||
policy: LogPolicy,
|
||||
response: HttpOperationResponse
|
||||
): Promise<HttpOperationResponse> {
|
||||
policy.logger(`>> Request: ${JSON.stringify(response.request, undefined, 2)}`);
|
||||
policy.logger(`>> Response status code: ${response.status}`);
|
||||
const responseBody = response.bodyAsText;
|
||||
policy.logger(`>> Body: ${responseBody}`);
|
||||
return Promise.resolve(response);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue