Skip to content

Commit 3fa33de

Browse files
tracyboehrerstevengum
authored andcommitted
Fixes microsoft#1465 - Remove use of logger and replace with direct calls to console. (microsoft#1606)
1 parent c7a7842 commit 3fa33de

File tree

35 files changed

+74
-225
lines changed

35 files changed

+74
-225
lines changed

samples/javascript_nodejs/05.multi-turn-prompt/bots/dialogBot.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,20 @@ class DialogBot extends ActivityHandler {
99
* @param {ConversationState} conversationState
1010
* @param {UserState} userState
1111
* @param {Dialog} dialog
12-
* @param {any} logger object for logging events, defaults to console if none is provided
1312
*/
14-
constructor(conversationState, userState, dialog, logger) {
13+
constructor(conversationState, userState, dialog) {
1514
super();
1615
if (!conversationState) throw new Error('[DialogBot]: Missing parameter. conversationState is required');
1716
if (!userState) throw new Error('[DialogBot]: Missing parameter. userState is required');
1817
if (!dialog) throw new Error('[DialogBot]: Missing parameter. dialog is required');
19-
if (!logger) {
20-
logger = console;
21-
logger.log('[DialogBot]: logger not passed in, defaulting to console');
22-
}
2318

2419
this.conversationState = conversationState;
2520
this.userState = userState;
2621
this.dialog = dialog;
27-
this.logger = logger;
2822
this.dialogState = this.conversationState.createProperty('DialogState');
2923

3024
this.onMessage(async (context, next) => {
31-
this.logger.log('Running dialog with Message Activity.');
25+
console.log('Running dialog with Message Activity.');
3226

3327
// Run the Dialog with the new message Activity.
3428
await this.dialog.run(context, this.dialogState);

samples/javascript_nodejs/05.multi-turn-prompt/dialogs/userProfileDialog.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,11 @@ const USER_PROFILE = 'USER_PROFILE';
2222
const WATERFALL_DIALOG = 'WATERFALL_DIALOG';
2323

2424
class UserProfileDialog extends ComponentDialog {
25-
constructor(userState, logger) {
25+
constructor(userState) {
2626
super('userProfileDialog');
2727

2828
this.userProfile = userState.createProperty(USER_PROFILE);
2929

30-
this.logger = logger;
31-
3230
this.addDialog(new TextPrompt(NAME_PROMPT));
3331
this.addDialog(new ChoicePrompt(CHOICE_PROMPT));
3432
this.addDialog(new ConfirmPrompt(CONFIRM_PROMPT));

samples/javascript_nodejs/05.multi-turn-prompt/index.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,9 @@ const memoryStorage = new MemoryStorage();
4141
const conversationState = new ConversationState(memoryStorage);
4242
const userState = new UserState(memoryStorage);
4343

44-
// Pass in a logger to the bot. For this sample, the logger is the console, but alternatives such as Application Insights and Event Hub exist for storing the logs of the bot.
45-
const logger = console;
46-
4744
// Create the main dialog.
48-
const dialog = new UserProfileDialog(userState, logger);
49-
const bot = new DialogBot(conversationState, userState, dialog, logger);
45+
const dialog = new UserProfileDialog(userState);
46+
const bot = new DialogBot(conversationState, userState, dialog);
5047

5148
// Create HTTP server.
5249
let server = restify.createServer();

samples/javascript_nodejs/06.using-cards/bots/dialogBot.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,20 @@ class DialogBot extends ActivityHandler {
1616
* @param {ConversationState} conversationState
1717
* @param {UserState} userState
1818
* @param {Dialog} dialog
19-
* @param {any} logger object for logging events, defaults to console if none is provided
2019
*/
21-
constructor(conversationState, userState, dialog, logger) {
20+
constructor(conversationState, userState, dialog) {
2221
super();
2322
if (!conversationState) throw new Error('[DialogBot]: Missing parameter. conversationState is required');
2423
if (!userState) throw new Error('[DialogBot]: Missing parameter. userState is required');
2524
if (!dialog) throw new Error('[DialogBot]: Missing parameter. dialog is required');
26-
if (!logger) {
27-
logger = console;
28-
logger.log('[DialogBot]: logger not passed in, defaulting to console');
29-
}
3025

3126
this.conversationState = conversationState;
3227
this.userState = userState;
3328
this.dialog = dialog;
34-
this.logger = logger;
3529
this.dialogState = this.conversationState.createProperty('DialogState');
3630

3731
this.onMessage(async (context, next) => {
38-
this.logger.log('Running dialog with Message Activity.');
32+
console.log('Running dialog with Message Activity.');
3933

4034
// Run the Dialog with the new message Activity.
4135
await this.dialog.run(context, this.dialogState);

samples/javascript_nodejs/06.using-cards/bots/richCardsBot.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ const { DialogBot } = require('./dialogBot');
99
* that matches the user's selection.
1010
*/
1111
class RichCardsBot extends DialogBot {
12-
constructor(conversationState, userState, dialog, logger) {
13-
super(conversationState, userState, dialog, logger);
12+
constructor(conversationState, userState, dialog) {
13+
super(conversationState, userState, dialog);
1414

1515
this.onMembersAdded(async (context, next) => {
1616
const membersAdded = context.activity.membersAdded;

samples/javascript_nodejs/06.using-cards/dialogs/mainDialog.js

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,9 @@ const AdaptiveCard = require('../resources/adaptiveCard.json');
88
const MAIN_WATERFALL_DIALOG = 'mainWaterfallDialog';
99

1010
class MainDialog extends ComponentDialog {
11-
constructor(logger) {
11+
constructor() {
1212
super('MainDialog');
1313

14-
if (!logger) {
15-
logger = console;
16-
logger.log('[MainDialog]: logger not passed in, defaulting to console');
17-
}
18-
19-
this.logger = logger;
20-
2114
// Define the main dialog and its related components.
2215
this.addDialog(new ChoicePrompt('cardPrompt'));
2316
this.addDialog(new WaterfallDialog(MAIN_WATERFALL_DIALOG, [
@@ -53,7 +46,7 @@ class MainDialog extends ComponentDialog {
5346
* @param {WaterfallStepContext} stepContext
5447
*/
5548
async choiceCardStep(stepContext) {
56-
this.logger.log('MainDialog.choiceCardStep');
49+
console.log('MainDialog.choiceCardStep');
5750

5851
// Create the PromptOptions which contain the prompt and re-prompt messages.
5952
// PromptOptions also contains the list of choices available to the user.
@@ -73,7 +66,7 @@ class MainDialog extends ComponentDialog {
7366
* @param {WaterfallStepContext} stepContext
7467
*/
7568
async showCardStep(stepContext) {
76-
this.logger.log('MainDialog.showCardStep');
69+
console.log('MainDialog.showCardStep');
7770

7871
switch (stepContext.result.value) {
7972
case 'Adaptive Card':

samples/javascript_nodejs/06.using-cards/index.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,9 @@ const memoryStorage = new MemoryStorage();
4646
conversationState = new ConversationState(memoryStorage);
4747
userState = new UserState(memoryStorage);
4848

49-
// Pass in a logger to the bot. For this sample, the logger is the console, but alternatives such as Application Insights and Event Hub exist for storing the logs of the bot.
50-
const logger = console;
51-
5249
// Create the main dialog.
53-
const dialog = new MainDialog(logger);
54-
const bot = new RichCardsBot(conversationState, userState, dialog, logger);
50+
const dialog = new MainDialog();
51+
const bot = new RichCardsBot(conversationState, userState, dialog);
5552

5653
// Create HTTP server.
5754
let server = restify.createServer();

samples/javascript_nodejs/11.qnamaker/bots/QnABot.js

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,8 @@ const { ActivityHandler } = require('botbuilder');
55
const { QnAMaker } = require('botbuilder-ai');
66

77
class QnABot extends ActivityHandler {
8-
/**
9-
* @param {any} logger object for logging events, defaults to console if none is provided
10-
*/
11-
constructor(logger) {
8+
constructor() {
129
super();
13-
if (!logger) {
14-
logger = console;
15-
logger.log('[QnaMakerBot]: logger not passed in, defaulting to console');
16-
}
1710

1811
try {
1912
this.qnaMaker = new QnAMaker({
@@ -22,9 +15,8 @@ class QnABot extends ActivityHandler {
2215
host: process.env.QnAEndpointHostName
2316
});
2417
} catch (err) {
25-
logger.warn(`QnAMaker Exception: ${ err } Check your QnAMaker configuration in .env`);
18+
console.warn(`QnAMaker Exception: ${ err } Check your QnAMaker configuration in .env`);
2619
}
27-
this.logger = logger;
2820

2921
// If a new user is added to the conversation, send them a greeting message
3022
this.onMembersAdded(async (context, next) => {
@@ -41,7 +33,7 @@ class QnABot extends ActivityHandler {
4133

4234
// When a user sends a message, perform a call to the QnA Maker service to retrieve matching Question and Answer pairs.
4335
this.onMessage(async (context, next) => {
44-
this.logger.log('Calling QnA Maker');
36+
console.log('Calling QnA Maker');
4537

4638
const qnaResults = await this.qnaMaker.getAnswers(context);
4739

samples/javascript_nodejs/11.qnamaker/index.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,8 @@ adapter.onTurnError = async (context, error) => {
3434
await context.sendActivity(`Oops. Something went wrong!`);
3535
};
3636

37-
// Pass in a logger to the bot. For this sample, the logger is the console, but alternatives such as Application Insights and Event Hub exist for storing the logs of the bot.
38-
const logger = console;
39-
4037
// Create the main dialog.
41-
const bot = new QnABot(logger);
38+
const bot = new QnABot();
4239

4340
// Create HTTP server
4441
let server = restify.createServer();

samples/javascript_nodejs/13.core-bot/bots/dialogAndWelcomeBot.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ const { DialogBot } = require('./dialogBot');
66
const WelcomeCard = require('./resources/welcomeCard.json');
77

88
class DialogAndWelcomeBot extends DialogBot {
9-
constructor(conversationState, userState, dialog, logger) {
10-
super(conversationState, userState, dialog, logger);
9+
constructor(conversationState, userState, dialog) {
10+
super(conversationState, userState, dialog);
1111

1212
this.onMembersAdded(async (context, next) => {
1313
const membersAdded = context.activity.membersAdded;

0 commit comments

Comments
 (0)