Skip to content

Update project logs #591

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Dec 7, 2021
Merged

Update project logs #591

merged 13 commits into from
Dec 7, 2021

Conversation

anthmatic
Copy link
Contributor

@anthmatic anthmatic commented Nov 9, 2021

Description and Context

Updates hs project logs to work with both endpoint and appFunction logs

To retrieve endpoint logs:
hs project logs --function=endpoint/name

To retrieve appFunction logs
hs project logs --function=appFunctionName --appPath=app

Testing

Commands to run:

Endpoint logs:
hs project logs --function=endpoint/name
Tail Endpoint logs:
hs project logs --function=endpoint/name -follow

App function logs:
hs project logs --function=appFunctionName --appPath=app
Tail app function logs:
hs project logs --function=appFunctionName --appPath=app --follow

Screenshots

TODO

Who to Notify

@anthmatic anthmatic mentioned this pull request Nov 9, 2021
@markhazlewood
Copy link

Couple comments/questions about the params:

  • --functionName - Propose we shorten this to just --function. In general including "name" in the label for something is redundant unless there's another common way to identify it. In this case I think function is clear enough.
  • --appPath - What exactly is this a path to? Is this still using the DFS tree path of the app.json file? If so, I'm not sure that's the best identifier since in the current workflow we don't surface the DFS file tree. Can we just provide a unique name and use --app instead?

@anthmatic
Copy link
Contributor Author

Changing to --function makes sense to me.

--appPath refers to the path to the app within your project. Using https://github.com/HubSpot/getting-started-project-template as an example, the value for this option would be app

@anthmatic anthmatic marked this pull request as ready for review November 19, 2021 17:21
@@ -77,7 +77,7 @@ const endpointLog = async (accountId, options) => {
};

exports.command = 'logs [endpoint]';
exports.describe = 'get logs for a function';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this logs command only work for project functions now?

const { getProjectConfig } = require('../../lib/projects');
const { loadAndValidateOptions } = require('../../lib/validation');
const { tailLogs } = require('../../lib/serverlessLogs');

const handleLogsError = (e, accountId, projectName, appPath, functionName) => {
if (e.statusCode === 404) {
logger.error(
`No logs were found for the function name '${functionName}' in the app path '${appPath}' within the project '${projectName}' in account ${accountId}.`
appPath
? `No logs were found for the function name '${functionName}' in the app path '${appPath}' within the project '${projectName}' in account ${accountId}.`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any way to rephrase this? It's four prepositional phrases in a row, I'm getting a little lost. Perhaps we could consult Erin.

Copy link
Contributor

@miketalley miketalley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<Ignore this comment, was a typo>

@@ -77,7 +77,7 @@ const endpointLog = async (accountId, options) => {
};

exports.command = 'logs [endpoint]';
exports.describe = 'get logs for a function';
exports.describe = 'get logs for a function within a project';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this only used to get logs for functions within a project? What about functions outside of projects?

appPath: {
describe: 'Path to app folder, relative to project',
type: 'string',
},
projectName: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be required? I get a TypeError when running hs project logs and only specifying --functionName...
image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +445 to +446
noAppFunctionLogs: "No logs were found for the function name \"{{ functionName }}\" in the app path \"{{ appPath }}\" within the project \"{{ projectName }}\" in account {{ accountId }}."
noEndpointLogs: "No logs were found for the function name \"{{ functionName }}\" within the project \"{{ projectName }}\" in account {{ accountId }}."
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@erincouse was hoping to get your feedback on these errors. They're shown when no logs are found

cc @kemmerle

@anthmatic anthmatic merged commit 08c336c into master Dec 7, 2021
@anthmatic anthmatic deleted the project-logs-v2 branch December 7, 2021 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants