Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upAdd core logger package #226
Conversation
coveralls
commented
Feb 18, 2019
•
| @@ -0,0 +1,24 @@ | |||
| { | |||
This comment has been minimized.
This comment has been minimized.
mjc1283
Feb 20, 2019
Contributor
I have some tsconfig suggestions:
- use
tsc --initto generate a tsconfig that contains comments explaining all the options "strict": truereplacing the individual strict options"noUnusedLocals: true"- Check whether
"importHelpers": true, and addingtslibas a dependency, reduces the package size - Disable decorator-related options
- Remove
"jsx" - Remove
"noLib": false(isfalseby default)
| @@ -0,0 +1,70 @@ | |||
| import * as uuid from 'uuid' | |||
This comment has been minimized.
This comment has been minimized.
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.
This comment has been minimized.
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.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
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.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| // TODO test for enumerable properties only | ||
| }) | ||
|
|
||
| describe('objectValues', () => { |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| } | ||
|
|
||
| level = level.toUpperCase() | ||
| if (level === 'WARN') { |
This comment has been minimized.
This comment has been minimized.
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.
This comment has been minimized.
| error(message: string | Error, ...splat: any[]): void | ||
| } | ||
|
|
||
| export interface LogManager { |
This comment has been minimized.
This comment has been minimized.
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.
This comment has been minimized.
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.
This comment has been minimized.
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.
This comment has been minimized.
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.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| "extends": "../../tsconfig.json", | ||
| "compilerOptions": { | ||
| "outDir": "./lib", | ||
| "noImplicitAny": true, |
This comment has been minimized.
This comment has been minimized.
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.
This comment has been minimized.
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.
Add docstrings
Update naming to be Manager / LoggerFacade / Handler
Export classes instead of factory methods for createConsoleLogHandler


jordangarcia commentedFeb 18, 2019
•
edited
Summary
js-sdk-loggingpackage that supplies a consistent logging interface with error handlingjs-sdk-utilswhich are only utils, this package is meant to eventually replace theutils/fns.jsin theoptimizely-sdkpackageThis allows us to have other packages, such as the DatafileManager that leverage the LogFactory singleton.
Design doc for Core Logger Improvements
Test plan