Visitar URL original
Add core logger package by jordangarcia · Pull Request #226 · optimizely/javascript-sdk · GitHub
The Wayback Machine - https://web.archive.org/web/20200920090934/https://github.com/optimizely/javascript-sdk/pull/226
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

Add core logger package #226

Merged
merged 30 commits into from Feb 21, 2019
Merged

Add core logger package #226

merged 30 commits into from Feb 21, 2019

Conversation

@jordangarcia
Copy link
Contributor

jordangarcia commented Feb 18, 2019 •

Summary

  • Add js-sdk-logging package that supplies a consistent logging interface with error handling
  • Add js-sdk-utils which are only utils, this package is meant to eventually replace the utils/fns.js in the optimizely-sdk package

This allows us to have other packages, such as the DatafileManager that leverage the LogFactory singleton.

Design doc for Core Logger Improvements

Test plan

  • Unit tests
@jordangarcia jordangarcia requested a review from mjc1283 Feb 18, 2019
@coveralls
Copy link

coveralls commented Feb 18, 2019 •

Coverage Status

Coverage remained the same at 97.587% when pulling a797141 on jordan/add-core-logger into 521225e on master.

@jordangarcia jordangarcia changed the title Add core package Add core logger package Feb 19, 2019
@jordangarcia jordangarcia requested a review from mikeng13 Feb 19, 2019
@@ -0,0 +1,24 @@
{

This comment has been minimized.

@mjc1283

mjc1283 Feb 20, 2019 Contributor

I have some tsconfig suggestions:

  • use tsc --init to generate a tsconfig that contains comments explaining all the options
  • "strict": true replacing the individual strict options
  • "noUnusedLocals: true"
  • Check whether "importHelpers": true, and adding tslib as a dependency, reduces the package size
  • Disable decorator-related options
  • Remove "jsx"
  • Remove "noLib": false (is false by default)
@@ -0,0 +1,70 @@
import * as uuid from 'uuid'

This comment has been minimized.

@mjc1283

mjc1283 Feb 20, 2019 Contributor

Several exports of the utils module, such as groupBy and objectValues, are unused. Why are we adding them?

This comment has been minimized.

@jordangarcia

jordangarcia Feb 21, 2019 Author Contributor

They are used in other packages that we will use in the near future.

// "./src"
// ],
"transform": {
"^.+\\.tsx?$": "ts-jest"

This comment has been minimized.

@mjc1283

mjc1283 Feb 20, 2019 Contributor

Why tsx?

This comment has been minimized.

@jordangarcia

jordangarcia Feb 21, 2019 Author Contributor

this is jsut copy/pasted

Doesn't hurt to have thsi in here though

}

/**
* Valids a valid is a valid TypeScript enum

This comment has been minimized.

@mjc1283

mjc1283 Feb 20, 2019 Contributor

Nit: grammar

This comment has been minimized.

@jordangarcia

jordangarcia Feb 21, 2019 Author Contributor

hahahahaha

// TODO test for enumerable properties only
})

describe('objectValues', () => {

This comment has been minimized.

@mjc1283

mjc1283 Feb 20, 2019 Contributor

Two describe blocks here for 'objectValues' - mistake?

This comment has been minimized.

@jordangarcia

jordangarcia Feb 21, 2019 Author Contributor

will remove

}

level = level.toUpperCase()
if (level === 'WARN') {

This comment has been minimized.

@mjc1283

mjc1283 Feb 20, 2019 Contributor

I see how this coercion is nice for usability, but it seems weird that we are treating 'WARN' as a special case. Why 'WARN' and not also 'ERR'?

This comment has been minimized.

@jordangarcia

jordangarcia Feb 21, 2019 Author Contributor

warn is the standard. for instance console.warn.

error(message: string | Error, ...splat: any[]): void
}

export interface LogManager {

This comment has been minimized.

@mjc1283

mjc1283 Feb 20, 2019 Contributor

If there is only one class implementing LogManager, and there only will ever be one, what do we gain by declaring this interface?

This comment has been minimized.

@jordangarcia

jordangarcia Feb 21, 2019 Author Contributor

I think the idea of making LogManager something replaceable is something we might want to do in the future.

Also the three main components are LogManager LogHandler and LoggerFacade so it seemed like good documentation to have them here.

return stringToLogLevel[level]
}

type LogData = {

This comment has been minimized.

@mjc1283

mjc1283 Feb 20, 2019 Contributor

Why is LogData declared as a type alias, as opposed to an interface? Same question also for other uses of type in this module.

This comment has been minimized.

@jordangarcia

jordangarcia Feb 21, 2019 Author Contributor

It's not going to be extended or reused outside of this file. My general rule of thumb is to use interfaces if they are going to be extended.

return
}

// TODO turn this into a format log function

This comment has been minimized.

@mjc1283

mjc1283 Feb 20, 2019 Contributor

What does it mean to turn this into a format log function?

This comment has been minimized.

@jordangarcia

jordangarcia Feb 21, 2019 Author Contributor

it's already done, will remove the TODO

"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "./lib",
"noImplicitAny": true,

This comment has been minimized.

@mjc1283

mjc1283 Feb 21, 2019 Contributor

Don't need noImplicitAny and strictNullChecks here - same as the parent config.


/* Strict Type-Checking Options */
"strict": true /* Enable all strict type-checking options. */,
"noImplicitAny": true /* Raise error on expressions and declarations with an implied 'any' type. */,

This comment has been minimized.

@mjc1283

mjc1283 Feb 21, 2019 Contributor

I think if "strict" is true it has the same effect of setting all of noImplicityAny, strictNullChecks, etc. (everything listed here under Strict Type-Checking Options) to true.

@jordangarcia jordangarcia force-pushed the jordan/add-core-logger branch from 33604f4 to 20a8357 Feb 21, 2019
@jordangarcia jordangarcia merged commit 78ba995 into master Feb 21, 2019
3 checks passed
3 checks passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage remained the same at 97.587%
Details
optimizely/fullstack-sdk-compatibility-suite (javascript) Build result: success
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.