Skip to content
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

clasp logs returns strange output #216

Closed
nirazul opened this issue Jun 9, 2018 · 8 comments
Closed

clasp logs returns strange output #216

nirazul opened this issue Jun 9, 2018 · 8 comments

Comments

@nirazul
Copy link
Contributor

nirazul commented Jun 9, 2018

Expected Behavior

Returns logs from Logger.log('stuff')

Actual Behavior

Returns the following:

NOTICE     2018-02-16T09:57:48.779Z N/A [object Object]
NOTICE     2018-02-16T09:57:50.111Z N/A [object Object]
NOTICE     2018-02-16T09:57:50.800Z N/A [object Object]
NOTICE     2018-02-16T09:57:51.520Z N/A [object Object]
NOTICE     2018-02-16T09:58:25.946Z N/A [object Object]
NOTICE     2018-02-16T09:58:26.353Z N/A [object Object]
(node:78635) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Cannot read property 'message' of undefined
(node:78635) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

instead of Logs

Steps to Reproduce the Problem

As this error might be a google project config problem, there's no poit in trying to reproduce it.

Specifications

  • Node version: 9
  • Version: 1.3.2
  • OS: Mac
@shai
Copy link

shai commented Jun 12, 2018

I'm having this same issue. Also, I don't know why isn't starting from the end, these logs are very old and I've got up-to-date logs that should been retrieved.

C:\Users\shai\mycode>clasp logs
NOTICE     2018-06-07T06:19:17.337Z N/A [object Object]
NOTICE     2018-06-07T06:19:19.843Z N/A [object Object]
NOTICE     2018-06-07T06:19:20.337Z N/A [object Object]
NOTICE     2018-06-07T06:19:21.414Z N/A [object Object]
(node:19104) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'message' of undefined
    at printLogs (C:\Users\shai\AppData\Roaming\npm\node_modules\@google\clasp\src\commands.js:297:67)
    at Object.<anonymous> (C:\Users\shai\AppData\Roaming\npm\node_modules\@google\clasp\src\commands.js:346:17)
    at step (C:\Users\shai\AppData\Roaming\npm\node_modules\@google\clasp\src\commands.js:32:23)
    at Object.next (C:\Users\shai\AppData\Roaming\npm\node_modules\@google\clasp\src\commands.js:13:53)
    at fulfilled (C:\Users\shai\AppData\Roaming\npm\node_modules\@google\clasp\src\commands.js:4:58)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
(node:19104) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:19104) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
  • Node version (node -v):
    v8.11.2
  • Version (npm list -g | grep clasp):
    +-- @google/[email protected]
  • OS (Mac/Linux/Windows):
OS Name:                   Microsoft Windows 10 Pro
OS Version:                10.0.14393 N/A Build 14393

@grant
Copy link
Contributor

grant commented Jun 12, 2018

Thanks for reporting this detailed issue first of all. clasp logs is still a bit experimental. Notes:

  1. clasp logs only work with StackDriver logs (console.log, not Logger.log)
  2. Thanks for the version info.

I'll test this function and will have to fix this.

@campionfellin
Copy link
Collaborator

Hey @nirazul and @shai hopefully I can give some clarity on this. Those first few logs that you see with NOTICE 2018-06-07T06:19:17.337Z N/A [object Object] etc. look like this:

{ protoPayload:
   { '@type': 'type.googleapis.com/google.cloud.audit.AuditLog',
     status: {},
     authenticationInfo: { principalEmail: '[email protected]' },
     requestMetadata: { callerIp: 'xx.xx.xxxx' },
     serviceName: 'clientauthconfig.googleapis.com',
     methodName: 'CreateBrand',
     authorizationInfo: [ [Object] ],
     resourceName: 'brands/xxxxxx',
     request: { brand: [Object] },
     response:
      { supportEmail: '[email protected]',
        displayName: 'myTitle',
        review: [Object],
        brandId: 'xxxx',
        updateTime: '2018-06-06T02:20:56.402287Z',
        projectNumbers: [Array] } },
  insertId: 'xxxxxx',
  resource:
   { type: 'client_auth_config_brand',
     labels:
      { brand_id: 'xxxxxx',
        project_id: 'project-id-xxxx' } },
  timestamp: '2018-06-06T02:20:56.100Z',
  severity: 'NOTICE',
  logName: 'projects/project-id-xxxx/logs/cloudaudit.googleapis.com%2Factivity',
  receiveTimestamp: '2018-06-06T02:20:57.285206438Z' }

which, to my understanding is just Apps Scripts setting up the StackDriver logging.

You can see that in the StackDriver Logging UI with this URL https://console.cloud.google.com/logs/viewer?project=project-id-xxxxxxxx&resource=project (replacing xxxxx with your project-id. You can also get there through StackDriver by clicking here:

screen shot 2018-06-16 at 3 49 22 pm

However, when using clasp logs I think we should either hide these logs or give them a friendlier message.

As far as getting older logs, it looks like the API has it set to old --> new by default. I can go ahead and switch that to get most recent first.

Please let me know if this helps, and what else you'd like to see improved!

grant pushed a commit that referenced this issue Jun 17, 2018
Changes ordering of logs and also fixes error that looks like this:

```
(node:20742) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Cannot read property 'length' of undefined
(node:20742) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
```
when entries is undefined.

Signed-off-by: campionfellin <[email protected]>

Relates to #216 

- [x] `npm run test` succeeds.
- [x] `npm run lint` succeeds.
- [ ] Appropriate changes to README are included in PR.
@shai
Copy link

shai commented Jun 17, 2018

Dear @campionfellin ,

which, to my understanding is just Apps Scripts setting up the StackDriver logging.

I've actually was able to figure this out, since I was able to reference the timestamp from the console to those logs in the UI and already knew these logs belonged to the initialisation of the service.

However, when using clasp logs I think we should either hide these logs or give them a friendlier message.

I would love to see that improve, for sure. I'm sure no-one else would want to see an exception here.

As far as getting older logs, it looks like the API has it set to old --> new by default. I can go ahead and switch that to get most recent first.

Please, do!

Please let me know if this helps, and what else you'd like to see improved!

I love the spirit and I'm sure that the more I use clasp, the more input I'll be able to provide in the future. I really appreciate your comments on this thread and your continued work in this project!

@campionfellin
Copy link
Collaborator

Hey @shai , glad you were able to figure that out! @grant what do you think of just not showing those types of logs?

This PR #221 makes it so it now shows most recent first. You can either download and build clasp yourself to use it, or wait for the next release!

@grant
Copy link
Contributor

grant commented Jun 17, 2018

Sounds good.
Let's document the log skipping (NOTICE: client_auth_config_brand) in the code.

@campionfellin Are there more changes we should make? LMK when we should cut a new release with the clasp logs improvements.

@campionfellin
Copy link
Collaborator

@grant I'll go ahead and make a change so it displays that message.

As far as other changes, there is this: #219 but I'm not sure if it fits in with this release. I'll look through some stuff today and maybe plan to release tomorrow?

@campionfellin campionfellin mentioned this issue Jun 17, 2018
3 tasks
@shai
Copy link

shai commented Jun 17, 2018

You guys are awesome! Thanks for taking this issue and applying a fix for it so quickly :) Looking forward to the next release...

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

No branches or pull requests

4 participants