Skip to content

Commit c1d9d86

Browse files
committed
Capitalze log msgs
1 parent 96ee0df commit c1d9d86

File tree

10 files changed

+39
-35
lines changed

10 files changed

+39
-35
lines changed

adservice/ads_service.bal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ service "AdService" on new grpc:Listener(9099) {
5353
# + request - the request containing context
5454
# + return - the related/random ad response or else an error
5555
remote function GetAds(stubs:AdRequest request) returns stubs:AdResponse|error {
56-
log:printInfo(string `received ad request with context_keys=${request.context_keys.toString()}`);
56+
log:printInfo(string `Received ad request with context_keys=${request.context_keys.toString()}`);
5757

5858
stubs:Ad[] ads = [];
5959
foreach string category in request.context_keys {

checkoutservice/checkout_service.bal

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ service "CheckoutService" on new grpc:Listener(9094) {
9494
# + request - `PlaceOrderRequest` containing user details
9595
# + return - returns `PlaceOrderResponse` containing order details
9696
remote function PlaceOrder(stubs:PlaceOrderRequest request) returns stubs:PlaceOrderResponse|grpc:Error|error {
97-
log:printInfo(string `received place order request with user_id=${request.user_id} user_currency=${request.user_currency}`);
97+
log:printInfo(string `Received place order request with user_id=${request.user_id} user_currency=${request.user_currency}`);
9898

9999
string orderId = uuid:createType1AsString();
100100
stubs:CartItem[] userCartItems = check self.getUserCartItems(request.user_id, request.user_currency);
@@ -114,7 +114,7 @@ service "CheckoutService" on new grpc:Listener(9094) {
114114
}
115115

116116
string transactionId = check self.chargeCard(totalCost, request.credit_card);
117-
log:printInfo(string `payment went through ${transactionId}`);
117+
log:printInfo(string `Payment went through ${transactionId}`);
118118
string shippingTrackingId = check self.shipOrder(request.address, userCartItems);
119119
check self.emptyUserCart(request.user_id);
120120

@@ -128,9 +128,9 @@ service "CheckoutService" on new grpc:Listener(9094) {
128128

129129
stubs:Empty|grpc:Error result = self.sendConfirmationMail(request.email, 'order);
130130
if result is grpc:Error {
131-
log:printWarn(string `failed to send order confirmation to ${request.email}`, result);
131+
log:printWarn(string `Failed to send order confirmation to ${request.email}`, result);
132132
} else {
133-
log:printInfo(string `order confirmation email sent to ${request.email}`);
133+
log:printInfo(string `Order confirmation email sent to ${request.email}`);
134134
}
135135

136136
return {'order};
@@ -140,7 +140,7 @@ service "CheckoutService" on new grpc:Listener(9094) {
140140
stubs:GetCartRequest getCartRequest = {user_id: userId};
141141
stubs:Cart|grpc:Error cartResponse = self.cartClient->GetCart(getCartRequest);
142142
if cartResponse is grpc:Error {
143-
log:printError("failed to call getCart of cart service", cartResponse);
143+
log:printError("Failed to call getCart of cart service", cartResponse);
144144
return cartResponse;
145145
}
146146
return cartResponse.items;
@@ -152,7 +152,7 @@ service "CheckoutService" on new grpc:Listener(9094) {
152152
stubs:GetProductRequest productRequest = {id: item.product_id};
153153
stubs:Product|grpc:Error productResponse = self.catalogClient->GetProduct(productRequest);
154154
if productResponse is grpc:Error {
155-
log:printError("failed to call getProduct from catalog service", productResponse);
155+
log:printError("Failed to call getProduct from catalog service", productResponse);
156156
return error grpc:InternalError(
157157
string `failed to get product ${item.product_id}`, productResponse);
158158
}
@@ -164,7 +164,7 @@ service "CheckoutService" on new grpc:Listener(9094) {
164164

165165
stubs:Money|grpc:Error conversionResponse = self.currencyClient->Convert(conversionRequest);
166166
if conversionResponse is grpc:Error {
167-
log:printError("failed to call convert from currency service", conversionResponse);
167+
log:printError("Failed to call convert from currency service", conversionResponse);
168168
return error grpc:InternalError(string `failed to convert price of ${item.product_id} to
169169
${userCurrency}`, conversionResponse);
170170
}
@@ -183,7 +183,7 @@ service "CheckoutService" on new grpc:Listener(9094) {
183183
};
184184
stubs:GetQuoteResponse|grpc:Error getQuoteResponse = self.shippingClient->GetQuote(quoteRequest);
185185
if getQuoteResponse is grpc:Error {
186-
log:printError("failed to call getQuote from shipping service", getQuoteResponse);
186+
log:printError("Failed to call getQuote from shipping service", getQuoteResponse);
187187
return error grpc:InternalError(
188188
string `failed to get shipping quote: ${getQuoteResponse.message()}`, getQuoteResponse);
189189
}
@@ -197,7 +197,7 @@ service "CheckoutService" on new grpc:Listener(9094) {
197197
};
198198
stubs:Money|grpc:Error convertionResponse = self.currencyClient->Convert(conversionRequest);
199199
if convertionResponse is grpc:Error {
200-
log:printError("failed to call convert from currency service", convertionResponse);
200+
log:printError("Failed to call convert from currency service", convertionResponse);
201201
return error grpc:InternalError(
202202
string `failed to convert currency: ${convertionResponse.message()}`, convertionResponse);
203203
}
@@ -211,7 +211,7 @@ service "CheckoutService" on new grpc:Listener(9094) {
211211
};
212212
stubs:ChargeResponse|grpc:Error chargeResponse = self.paymentClient->Charge(chargeRequest);
213213
if chargeResponse is grpc:Error {
214-
log:printError("failed to call charge from payment service", chargeResponse);
214+
log:printError("Failed to call charge from payment service", chargeResponse);
215215
return error grpc:InternalError(
216216
string `could not charge the card: ${chargeResponse.message()}`, chargeResponse);
217217
}
@@ -222,7 +222,7 @@ service "CheckoutService" on new grpc:Listener(9094) {
222222
stubs:ShipOrderRequest orderRequest = {};
223223
stubs:ShipOrderResponse|grpc:Error shipOrderResponse = self.shippingClient->ShipOrder(orderRequest);
224224
if shipOrderResponse is grpc:Error {
225-
log:printError("failed to call shipOrder from shipping service", shipOrderResponse);
225+
log:printError("Failed to call shipOrder from shipping service", shipOrderResponse);
226226
return error grpc:UnavailableError(
227227
string `shipment failed: ${shipOrderResponse.message()}`, shipOrderResponse);
228228
}
@@ -235,7 +235,7 @@ service "CheckoutService" on new grpc:Listener(9094) {
235235
};
236236
stubs:Empty|grpc:Error emptyCart = self.cartClient->EmptyCart(request);
237237
if emptyCart is grpc:Error {
238-
log:printError("failed to call emptyCart from cart service", emptyCart);
238+
log:printError("Failed to call emptyCart from cart service", emptyCart);
239239
return error grpc:InternalError(
240240
string `failed to empty user cart during checkout: ${emptyCart.message()}`, emptyCart);
241241
}

emailservice/email_service.bal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ service "EmailService" on new grpc:Listener(9097) {
5959
# + request - `SendOrderConfirmationRequest` which contains the details about the order
6060
# + return - `Empty` or else an error
6161
remote function SendOrderConfirmation(stubs:SendOrderConfirmationRequest request) returns stubs:Empty|error {
62-
log:printInfo(string `received send order confirmation request with email ${request.email}.`);
62+
log:printInfo(string `Received send order confirmation request with email ${request.email}.`);
6363

6464
gmail:MessageRequest messageRequest = {
6565
recipient: request.email,

frontend/rpc.bal

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ final stubs:CheckoutServiceClient checkoutClient = check new (string `http://${c
8686
isolated function getSupportedCurrencies() returns string[]|grpc:Error {
8787
stubs:GetSupportedCurrenciesResponse|grpc:Error supportedCurrencies = currencyClient->GetSupportedCurrencies({});
8888
if supportedCurrencies is grpc:Error {
89-
log:printError("failed to get supported currencies from the currency service", supportedCurrencies);
89+
log:printError("Failed to get supported currencies from the currency service", supportedCurrencies);
9090
return supportedCurrencies;
9191
}
9292
return supportedCurrencies.currency_codes;
@@ -95,7 +95,7 @@ isolated function getSupportedCurrencies() returns string[]|grpc:Error {
9595
isolated function getProducts() returns stubs:Product[]|grpc:Error {
9696
stubs:ListProductsResponse|grpc:Error productsResponse = catalogClient->ListProducts({});
9797
if productsResponse is grpc:Error {
98-
log:printError("failed to list products from the catalog service", productsResponse);
98+
log:printError("Failed to list products from the catalog service", productsResponse);
9999
return productsResponse;
100100
}
101101
return productsResponse.products;
@@ -104,7 +104,7 @@ isolated function getProducts() returns stubs:Product[]|grpc:Error {
104104
isolated function getProduct(string id) returns stubs:Product|grpc:Error {
105105
stubs:Product|grpc:Error product = catalogClient->GetProduct({id});
106106
if product is grpc:Error {
107-
log:printError("failed to get product from the catalog service", product);
107+
log:printError("Failed to get product from the catalog service", product);
108108
}
109109
return product;
110110
}
@@ -114,7 +114,7 @@ isolated function getCart(string userId) returns stubs:Cart|grpc:Error {
114114
user_id: userId
115115
});
116116
if cart is grpc:Error {
117-
log:printError("failed to get cart from the cart service", cart);
117+
log:printError("Failed to get cart from the cart service", cart);
118118
}
119119
return cart;
120120
}
@@ -124,7 +124,7 @@ isolated function emptyCart(string userId) returns grpc:Error? {
124124
user_id: userId
125125
});
126126
if cart is grpc:Error {
127-
log:printError("failed to empty the cart", cart);
127+
log:printError("Failed to empty the cart", cart);
128128
return cart;
129129
}
130130
}
@@ -138,7 +138,7 @@ isolated function insertItemToCart(string userId, string productId, int quantity
138138
}
139139
});
140140
if response is grpc:Error {
141-
log:printError("failed to add item to the cart service", response);
141+
log:printError("Failed to add item to the cart service", response);
142142
return response;
143143
}
144144
}
@@ -149,7 +149,7 @@ isolated function convertCurrency(stubs:Money usd, string userCurrency) returns
149149
to_code: userCurrency
150150
});
151151
if convertedCurrency is grpc:Error {
152-
log:printError("failed to convert currency", convertedCurrency);
152+
log:printError("Failed to convert currency", convertedCurrency);
153153
}
154154
return convertedCurrency;
155155
}
@@ -159,7 +159,7 @@ isolated function getShippingQuote(stubs:CartItem[] items, string currency) retu
159159
items
160160
});
161161
if quote is grpc:Error {
162-
log:printError("failed to get quote from the shipping service", quote);
162+
log:printError("Failed to get quote from the shipping service", quote);
163163
return quote;
164164
}
165165
return convertCurrency(quote.cost_usd, currency);
@@ -171,7 +171,7 @@ isolated function getRecommendations(string userId, string[] productIds = []) re
171171
product_ids: ["2ZYFJ3GM2N", "LS4PSXUNUM"]
172172
});
173173
if recommendations is grpc:Error {
174-
log:printError("failed to list recommendations from the recommendation service", recommendations);
174+
log:printError("Failed to list recommendations from the recommendation service", recommendations);
175175
return recommendations;
176176
}
177177

@@ -183,7 +183,7 @@ isolated function getRecommendations(string userId, string[] productIds = []) re
183183
isolated function getAds(string[] context_keys) returns stubs:Ad[]|grpc:Error {
184184
stubs:AdResponse|grpc:Error adResponse = adClient->GetAds({context_keys});
185185
if adResponse is grpc:Error {
186-
log:printError("failed to get ads from the ads service", adResponse);
186+
log:printError("Failed to get ads from the ads service", adResponse);
187187
return adResponse;
188188
}
189189
return adResponse.ads;
@@ -197,7 +197,7 @@ isolated function chooseAd(string[] ctxKeys = []) returns stubs:Ad|error {
197197
isolated function checkoutCart(stubs:PlaceOrderRequest request) returns stubs:OrderResult|grpc:Error {
198198
stubs:PlaceOrderResponse|grpc:Error placeOrderResponse = checkoutClient->PlaceOrder(request);
199199
if placeOrderResponse is grpc:Error {
200-
log:printError("failed to place order from the checkout service", placeOrderResponse);
200+
log:printError("Failed to place order from the checkout service", placeOrderResponse);
201201
return placeOrderResponse;
202202
}
203203
return placeOrderResponse.'order;

money/money.bal

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
import wso2/client_stubs as stubs;
1818

19+
const FRACTION_SIZE = 1000000000;
20+
1921
public const map<string> CURRENCY_SYMBOLS = {
2022
"USD": "$",
2123
"CAD": "$",
@@ -143,4 +145,4 @@ public isolated function multiplySlow(stubs:Money money, int n) returns stubs:Mo
143145
# + money - `Money` value to be rendered
144146
# + return - rendered value as a string
145147
public isolated function renderMoney(stubs:Money money) returns string =>
146-
string `${CURRENCY_SYMBOLS.get(money.currency_code)}${money.units.toString()}.${(money.nanos / 10000000).toString()}`;
148+
string `${CURRENCY_SYMBOLS.get(money.currency_code)}${money.units.toString()}.${(money.nanos / FRACTION_SIZE).toString()}`;

paymentservice/payment_service.bal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ service "PaymentService" on new grpc:Listener(9096) {
3737
# + request - `ChargeRequest` containing the card details and the amount to charge
3838
# + return - `ChargeResponse` with the transaction id or an error
3939
remote function Charge(stubs:ChargeRequest request) returns stubs:ChargeResponse|error {
40-
log:printInfo(string `received charge request with ${request.toString()}`);
40+
log:printInfo(string `Received charge request with ${request.toString()}`);
4141

4242
var {credit_card_number: cardNumber, credit_card_expiration_year: year,
4343
credit_card_expiration_month: month} = request.credit_card;

productcatalogservice/catalog_service.bal

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ service "ProductCatalogService" on new grpc:Listener(9091) {
3434
function init() returns error? {
3535
json|error productsJson = io:fileReadJson(productJsonPath);
3636
if productsJson is error {
37-
log:printError("failed to open product catalog json file: ", productsJson);
37+
log:printError("Failed to open product catalog json file: ", productsJson);
3838
return productsJson;
3939
}
40-
log:printInfo("successfully parsed product catalog json");
40+
log:printInfo("Successfully parsed product catalog json");
4141
self.products = check parseProductJson(productsJson);
4242
log:printInfo("Catalog service gRPC server started.");
4343
}

productcatalogservice/utils.bal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ type JsonProduct readonly & record {|
3535
isolated function parseProductJson(json jsonContents) returns stubs:Product[] & readonly|error {
3636
json|error productsJson = jsonContents.products;
3737
if productsJson is error {
38-
log:printError("failed to parse the catalog JSON: ", productsJson);
38+
log:printError("Failed to parse the catalog JSON: ", productsJson);
3939
return productsJson;
4040
}
4141
if productsJson !is json[] {

recommendationservice/recommendation_service.bal

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ service "RecommendationService" on new grpc:Listener(9090) {
4747
# + return - `ListRecommendationsResponse` containing the recommended product ids
4848
remote function ListRecommendations(stubs:ListRecommendationsRequest request)
4949
returns stubs:ListRecommendationsResponse|error {
50-
log:printInfo(string `received list recommendations request with product_ids=${request.product_ids.toString()}`);
50+
log:printInfo(string `Received list recommendations request with product_ids=${request.product_ids.toString()}`);
5151
stubs:ListProductsResponse|grpc:Error listProducts = self.catalogClient->ListProducts({});
5252
if listProducts is grpc:Error {
53-
log:printError("failed to call ListProducts of catalog service", listProducts);
53+
log:printError("Failed to call ListProducts of catalog service", listProducts);
5454
return error grpc:InternalError("failed to get list of products from catalog service", listProducts);
5555
}
5656

shippingservice/shipping_service.bal

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import ballerina/log;
1919
import ballerinax/jaeger as _;
2020
import wso2/client_stubs as stubs;
2121

22+
const FRACTION_SIZE = 1000000000;
23+
2224
# Gives the shipping cost estimates based on the shopping cart.
2325
@display {
2426
label: "Shipping",
@@ -36,7 +38,7 @@ service "ShippingService" on new grpc:Listener(9095) {
3638
# + request - `GetQuoteRequest` contaning the user's selected items
3739
# + return - `GetQuoteResponse` containing the shipping cost
3840
remote function GetQuote(stubs:GetQuoteRequest request) returns stubs:GetQuoteResponse {
39-
log:printInfo(string `received get quote request with ${request.toString()}`);
41+
log:printInfo(string `Received get quote request with ${request.toString()}`);
4042

4143
stubs:CartItem[] items = request.items;
4244
int count = 0;
@@ -51,7 +53,7 @@ service "ShippingService" on new grpc:Listener(9095) {
5153
int dollars = <int>(cost - cents);
5254

5355
return {
54-
cost_usd: {currency_code: "USD", nanos: <int>(cents * 1000000000), units: dollars}
56+
cost_usd: {currency_code: "USD", nanos: <int>(cents * FRACTION_SIZE), units: dollars}
5557
};
5658
}
5759

@@ -60,7 +62,7 @@ service "ShippingService" on new grpc:Listener(9095) {
6062
# + request - `ShipOrderRequest` containing the address and the user's order items
6163
# + return - `ShipOrderResponse` containing the tracking id or an error
6264
remote function ShipOrder(stubs:ShipOrderRequest request) returns stubs:ShipOrderResponse {
63-
log:printInfo(string `received ship order request with ${request.toString()}`);
65+
log:printInfo(string `Received ship order request with ${request.toString()}`);
6466
stubs:Address address = request.address;
6567
return {
6668
tracking_id: generateTrackingId(string `${address.street_address}, ${address.city}, ${address.state}`)

0 commit comments

Comments
 (0)