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

feat(logging): add new logging category #12759

Merged

Conversation

ashwinkumar6
Copy link
Contributor

@ashwinkumar6 ashwinkumar6 commented Dec 27, 2023

Description of changes

  • Create new logging category
  • Add category APIs
    • enable
    • disable
    • flushLogs
    • createLogger
  • Add provider cloudwatch APIs
    • enable
    • disable
    • getProvider
  • Add provider console APIs
    • enable
    • disable
    • getProvider
  • Add placeholder unit tests for all APIs

Description of how you validated changes

verified apis are visible

import { 
  enable,
  disable,
  flushLogs,
  createLogger
} from "aws-amplify/logging";
import {
  getProvider as getConsoleProvider,
  enable as enableConsole,
  disable as disableConsole,
} from "aws-amplify/logging/console";
import {
  getProvider as getCloudWatchProvider,
  enable as enableCloudwatch,
  disable as disableCloudwatch,
} from "aws-amplify/logging/cloudwatch";

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@ashwinkumar6 ashwinkumar6 requested review from a team as code owners December 27, 2023 20:29
@ashwinkumar6 ashwinkumar6 changed the base branch from main to central-logger December 27, 2023 20:29
Copy link
Contributor

Choose a reason for hiding this comment

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

If the logger package is not expected to be published as CDN bundle, please remove Webpack related settings.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks, removed webpack related settings.

packages/logger/tsconfig.json Outdated Show resolved Hide resolved
packages/logger/package.json Outdated Show resolved Hide resolved
ashwinkumar6 and others added 5 commits December 28, 2023 15:55
Co-authored-by: Hui Zhao <10602282+HuiSF@users.noreply.github.com>
Co-authored-by: Hui Zhao <10602282+HuiSF@users.noreply.github.com>
Copy link
Contributor

@jimblanc jimblanc left a comment

Choose a reason for hiding this comment

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

Some comments, but overall looks good!

packages/logger/build.js Outdated Show resolved Hide resolved
packages/logger/index.js Outdated Show resolved Hide resolved
packages/logger/package.json Outdated Show resolved Hide resolved
packages/logger/package.json Outdated Show resolved Hide resolved
"tslib": "^2.5.0"
},
"peerDependencies": {
"@aws-amplify/core": "^6.0.0"
Copy link
Contributor

Choose a reason for hiding this comment

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

Not required yet, but at some point before merge we'll need to update this to the version that will contain the new logger utils (across all packages)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ahhhh yes got it, all packages having peerDependencies on core would need to update to use the latest core version. This to make sure they have access to latest logger that's implemented in core

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removing this for now, will add it back when required.
EDIT: added back (reference)

ashwinkumar6 and others added 3 commits January 4, 2024 10:37
Co-authored-by: Jim Blanchard <jim.l.blanchard@gmail.com>
Co-authored-by: Jim Blanchard <jim.l.blanchard@gmail.com>
Comment on lines 78 to 80
"peerDependencies": {
"@aws-amplify/core": "^6.0.0"
},
Copy link
Contributor

Choose a reason for hiding this comment

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

IMO we should leave this in place for our pre-publish script to update it during testing and so that we don't forget to update when we bump the other packages

Copy link
Contributor Author

Choose a reason for hiding this comment

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

makes sense, added back

@@ -0,0 +1,5 @@
{
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 reason this package still needs a separate build configuration, or can it just share the same tsconfig.json like most of our packages do now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this will be unified in the eslint migration, so we can keep it. wdyt

Copy link
Contributor

Choose a reason for hiding this comment

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

It depends on the timing of that vs this I think? If this feature branch is merged after that migration then it will be missed by the migration right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good point, adding a todo to make sure this is tracked

packages/logger/src/providers/cloudwatch/index.ts Outdated Show resolved Hide resolved
packages/logger/console/package.json Outdated Show resolved Hide resolved
packages/logger/jest.config.js Outdated Show resolved Hide resolved
@ashwinkumar6 ashwinkumar6 changed the title feat(logger): add new logger category feat(logging): add new logging category Jan 5, 2024
// SPDX-License-Identifier: Apache-2.0

// TODO: pending implementation
export const createLogger = (): void => {};
Copy link
Contributor

Choose a reason for hiding this comment

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

nit/suggestion: could define the actual return type here, and leave the implementation throw new Error('API has not been implemented.'), this would be more continuous.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that's a good point. We'll be wiring up all these PRs once the other Providers PR gets merged.
So we should shortly be replacing all these. If anything's pending will add the throw new Error('API has not been implemented.') wdyt

@ashwinkumar6 ashwinkumar6 merged commit 1d26ca8 into aws-amplify:central-logger Jan 10, 2024
29 checks passed
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.

None yet

4 participants