Skip to content

Commit

Permalink
ログを吐く
Browse files Browse the repository at this point in the history
  • Loading branch information
muryoimpl committed Jul 19, 2024
1 parent 5759038 commit 55390f8
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions command.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ function doPost(e) {
return targetSheet ? targetSheet : spreadsheet.insertSheet(name);
}(sheetName);

Logger.log({ cmd: cmd, user_name: e.parameter.user_name });

switch (cmd) {
case 'entry': { // エントリする
const current = new Date().toLocaleString();
Expand All @@ -76,6 +78,8 @@ function doPost(e) {
).setValues([entryLine]);
SpreadsheetApp.flush()

Logger.log({ cmd: cmd, user_name: e.parameter.user_name, title: title, argText: argText });

const payload = createMessagePayload(
`${userName} さんから LT: 「${title}」のエントリがありました。entryId: ${startRowNum + row}`
);
Expand All @@ -99,6 +103,8 @@ function doPost(e) {

sheet.getRange(targetRowNum, startColNum + index.STATUS).setValue(status.REMOVED);

Logger.log({ cmd: cmd, user_name: e.parameter.user_name, entryId: entryId });

const payload = createMessagePayload(
`LT title: ${entry[index.TITLE]} のエントリが取り消されました。`
);
Expand Down Expand Up @@ -126,11 +132,11 @@ function doPost(e) {
entryCount++;
}

if (entryCount === 0) {
return ContentService.createTextOutput(messages.no_entry);
} else {
return ContentService.createTextOutput(text);
}
if (entryCount === 0) text = messages.no_entry;

Logger.log({ cmd: cmd, user_name: e.parameter.user_name, text: text });

return ContentService.createTextOutput(text);
}

case 'list': { // shuffle されていないエントリを出力する
Expand All @@ -153,6 +159,8 @@ function doPost(e) {
entryCount++;
}

Logger.log({ cmd: cmd, user_name: e.parameter.user_name });

if (entryCount === 0) {
return ContentService.createTextOutput(messages.no_entry);
} else {
Expand Down Expand Up @@ -181,6 +189,8 @@ function doPost(e) {

if (!allText) allText = messages.no_entry;

Logger.log({ cmd: cmd, user_name: e.parameter.user_name, text: allText });

return ContentService.createTextOutput(allText);
}
case 'shuffle': { // shuffle されていないエントリをシャッフルする
Expand Down Expand Up @@ -230,6 +240,8 @@ function doPost(e) {
// markdown を作り、レスポンスを返す
const mdText = makeMarkdown(orderNumbers, container, status, index);

Logger.log({ cmd: cmd, user_name: e.parameter.user_name, text: mdText });

const payload = createMessagePayload(mdText);
return createPublicTextOutput(payload);
}
Expand Down Expand Up @@ -268,6 +280,8 @@ function doPost(e) {
).setValues([...values]);
SpreadsheetApp.flush()

Logger.log({ cmd: cmd, user_name: e.parameter.user_name, text: message.reset_order });

return ContentService.createTextOutput(messages.reset_order);
}
case 'delimit': {
Expand All @@ -290,10 +304,14 @@ function doPost(e) {
}
SpreadsheetApp.flush()

Logger.log({ cmd: cmd, user_name: e.parameter.user_name, text: message.delimit_time });

const payload = createMessagePayload(messages.delimit_time);
return createPublicTextOutput(payload);
}
default:
Logger.log({ cmd: cmd, user_name: e.parameter.user_name });

return ContentService.createTextOutput(cmd + "\n" + help);
}
}
Expand Down

0 comments on commit 55390f8

Please sign in to comment.