-
-
Notifications
You must be signed in to change notification settings - Fork 20
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
feature: extract lumberjack core into an agnostic library #154
Conversation
☁️ Nx Cloud ReportAttention: This version of the Nx Cloud GitHub bot will cease to function on July 1st, 2023. An organization admin can update your integration here. CI is running/has finished running commands for commit 735764c. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this branch ✅ Successfully ran 7 targets
Sent with 💌 from NxCloud. |
49cf544
to
2279cb7
Compare
8d64cb4
to
bfc6d1e
Compare
4c908ec
to
9df215b
Compare
bfc6d1e
to
2d38dd7
Compare
191c2bd
to
2c7f384
Compare
☁️ Nx Cloud ReportCI is running/has finished running commands for commit 91bf803. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this CI Pipeline Execution ✅ Successfully ran 5 targetsSent with 💌 from NxCloud. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Partial review of latest commits.
packages/ngworker/lumberjack/src/lib/formatting/lumberjack-log-formatter.service.ts
Outdated
Show resolved
Hide resolved
packages/webworker/lumberjack/src/lib/formatting/create-lumberjack-log-formatter.ts
Outdated
Show resolved
Hide resolved
return { | ||
formatLog, | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: Does it makes sense to return an object? Can't we just return a function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does make sense to return just a function. I was returning an object to keep it consistent with the other create*
factory functions on the workspace.
If you think is ok to just return a function, I'm happy with that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are the two possibilities:
Returning an object
const logFormatter = createLumberjackLogFormatter({ config, getUnixEpochTicks });
const { log, formattedLog } = logFormatter.formatLog(lumberjackLog);
Returning a function
const formatLog = createLumberjackLogFormatter({ config, getUnixEpochTicks });
const { log, formattedLog } = formatLog(lumberjackLog);
@@ -24,7 +25,7 @@ import { LumberjackTimeService } from '../time/lumberjack-time.service'; | |||
* API. | |||
*/ | |||
@Injectable() | |||
export class LumberjackService<TPayload extends LumberjackLogPayload | void = void> { | |||
export class LumberjackService<TPayload extends LumberjackLogPayload | void = void> implements Lumberjack<TPayload> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Can we please find a different name than LumberjackService
? See #166 (comment).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my article about Plugin Architecture I use the terms core system
and orchestrator
.
Do any of those terms resonate with you?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going with LumberjackOrchestrator
. But we can change later.
packages/webworker/lumberjack/src/lib/logging/create-lumberjack.ts
Outdated
Show resolved
Hide resolved
packages/webworker/lumberjack/src/lib/formatting/lumberjack-log-formatter-result.ts
Outdated
Show resolved
Hide resolved
packages/webworker/lumberjack/src/lib/logging/create-lumberjack.ts
Outdated
Show resolved
Hide resolved
packages/webworker/lumberjack/src/lib/logging/create-lumberjack-log-factory.ts
Outdated
Show resolved
Hide resolved
constructor( | ||
level: LumberjackLogLevel, | ||
message: string, | ||
getUnixEpochTicks: () => number = () => new Date().valueOf() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: Do we have an integration test that replaces getUnixEpochTicks
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In most tests, we use the fakeTime.getUnixEpochTicks
if that's what you were thinking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Request changes
- [@ngworker/lumberjack-applicationinsights-driver](https://github.com/ngworker/lumberjack-applicationinsights-driver), community log driver using [Azure Application Insights](https://docs.microsoft.com/en-us/azure/azure-monitor/app/app-insights-overview) as a log store. | ||
|
||
The ngworkers teams offers hosting of a community log driver in the [ngworker GitHub](https://github.com/ngworker) and [@ngworker NPM](https://www.npmjs.com/org/ngworker) organizations. | ||
The LumberjackJS team offers hosting of a community log driver in the [ngworker GitHub](https://github.com/ngworker) and [@ngworker NPM](https://www.npmjs.com/org/ngworker) organizations. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: the Lumberjack team (JS is just for getting an npm scope).
The LumberjackJS team offers hosting of a community log driver in the [ngworker GitHub](https://github.com/ngworker) and [@ngworker NPM](https://www.npmjs.com/org/ngworker) organizations. | |
The Lumberjack team offers hosting of a community log driver in the [ngworker GitHub](https://github.com/ngworker) and [@ngworker NPM](https://www.npmjs.com/org/ngworker) organizations. |
- [@ngworker/lumberjack-applicationinsights-driver](https://github.com/ngworker/lumberjack-applicationinsights-driver), community log driver using [Azure Application Insights](https://docs.microsoft.com/en-us/azure/azure-monitor/app/app-insights-overview) as a log store. | ||
|
||
The ngworkers teams offers hosting of a community log driver in the [ngworker GitHub](https://github.com/ngworker) and [@ngworker NPM](https://www.npmjs.com/org/ngworker) organizations. | ||
The LumberjackJS team offers hosting of a community log driver in the [ngworker GitHub](https://github.com/ngworker) and [@ngworker NPM](https://www.npmjs.com/org/ngworker) organizations. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue: update GitHub and npm organizations
The LumberjackJS team offers hosting of a community log driver in the [ngworker GitHub](https://github.com/ngworker) and [@ngworker NPM](https://www.npmjs.com/org/ngworker) organizations. | |
The LumberjackJS team offers hosting of a community log driver in the [lumberjackjs GitHub](https://github.com/lumberjackjs) and [@lumberjackjs NPM](https://www.npmjs.com/org/lumberjackjs) organizations. |
import { LumberjackConsoleDriverModule } from '@ngworker/lumberjack/console-driver'; | ||
import { LumberjackHttpDriverModule } from '@ngworker/lumberjack/http-driver'; | ||
import { LumberjackLevel, LumberjackModule } from '@lumberjackjs/angular'; | ||
import { LumberjackConsoleDriverModule } from '@lumberjackjs/angular/console-driver'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue: our decision is to not have an Angular-specific console driver package or secondary entry point if possible, that is there will be a @lumberjackjs/core/console-driver
package but no Angular console driver package
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is a good catch, but I fear I must do a profound rewrite of the docs. Also, write down the migration guide.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I checked, and the docs are in bad shape. I will rewrite them next weekend.
import { LumberjackHttpDriverModule } from '@ngworker/lumberjack/http-driver'; | ||
import { LumberjackLevel, LumberjackModule } from '@lumberjackjs/angular'; | ||
import { LumberjackConsoleDriverModule } from '@lumberjackjs/angular/console-driver'; | ||
import { LumberjackHttpDriverModule } from '@lumberjackjs/angular/http-driver'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue: correct the package name according to our decision
import { LumberjackHttpDriverModule } from '@lumberjackjs/angular/http-driver'; | |
import { LumberjackHttpDriverModule } from '@lumberjackjs/angular-http-driver'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will rewrite the whole documentation next week.
import { provideLumberjackConsoleDriver } from '@ngworker/lumberjack/console-driver'; | ||
import { provideLumberjackHttpDriver, withHttpConfig } from '@ngworker/lumberjack/http-driver'; | ||
import { LumberjackLevel, provideLumberjack } from '@lumberjackjs/angular'; | ||
import { provideLumberjackConsoleDriver } from '@lumberjackjs/angular/console-driver'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue: our decision is to not have an Angular-specific console driver package or secondary entry point if possible, that is there will be a @lumberjackjs/core/console-driver
package but no Angular console driver package
packages/internal/angular/console-driver/test-util/src/lib/spy-console/spy-console.module.ts
Outdated
Show resolved
Hide resolved
packages/internal/angular/console-driver/test-util/src/lib/spy-console/spy-console.service.ts
Outdated
Show resolved
Hide resolved
@@ -1,6 +1,6 @@ | |||
import { Injectable } from '@angular/core'; | |||
|
|||
import { LumberjackTimeService } from '@ngworker/lumberjack'; | |||
import { LumberjackTimeService } from '@lumberjackjs/angular'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: where do we place LumberjackTimeService
and will it have a different API?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the agnostic core, I have replaced it with a getUnixEpochTicks
function that can be passed to the createLumberjack
factory function.
By default it uses the () => new Date().valueof()
This is the complete method signature
export function createLumberjack<TPayload extends LumberjackLogPayload | void = void>({
drivers,
config,
getUnixEpochTicks = () => new Date().valueOf(),
}: LumberjackDependencies<TPayload>): Lumberjack<TPayload>
…angular-http-driver
…lient to use agnostic drivers
… carried createLogBuilderFunction
fa79538
to
1bd120f
Compare
Kudos, SonarCloud Quality Gate passed! |
See #188 |
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Lumberjack is a highly extensible and configurable logging library for Angular.
But why stop there?
What is the new behavior?
@webworker/lumberjack
is a framework-agnostic logging library; it powersngworker/lumberjack
and enables the creation of any framework-specific lumberjack implementation like Qwik, Solid, or React.Does this PR introduce a breaking change?
Other information
Although nothing changes for
@ngworker/lumberjack
, this refactoring should introduce a major version.