Rocket.Chat.Apps-engine
Rocket.Chat.Apps-engine copied to clipboard
[IMPROVE] Print the apps' logs on the terminal when in development mode
Preview:

Codecov Report
Merging #186 into master will increase coverage by
2.9%. The diff coverage is76.92%.
@@ Coverage Diff @@
## master #186 +/- ##
=========================================
+ Coverage 53.81% 56.72% +2.9%
=========================================
Files 70 77 +7
Lines 2568 2565 -3
Branches 380 371 -9
=========================================
+ Hits 1382 1455 +73
+ Misses 1186 1110 -76
| Impacted Files | Coverage Δ | |
|---|---|---|
| src/server/ProxiedApp.ts | 14.1% <0%> (+0.35%) |
:arrow_up: |
| src/server/compiler/AppCompiler.ts | 26.03% <0%> (ø) |
:arrow_up: |
| src/server/logging/AppConsole.ts | 98.24% <100%> (+0.2%) |
:arrow_up: |
| src/server/misc/DisabledApp.ts | 100% <100%> (ø) |
:arrow_up: |
| src/server/AppManager.ts | 14.73% <50%> (+0.45%) |
:arrow_up: |
| src/server/compiler/AppPackageParser.ts | 16.82% <0%> (-4.98%) |
:arrow_down: |
| src/server/managers/AppApiManager.ts | 96.15% <0%> (-0.08%) |
:arrow_down: |
| src/server/managers/AppListenerManager.ts | 4.5% <0%> (-0.06%) |
:arrow_down: |
| src/server/accessors/Notifier.ts | 100% <0%> (ø) |
:arrow_up: |
| src/server/compiler/AppImplements.ts | 100% <0%> (ø) |
:arrow_up: |
| ... and 20 more |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing dataPowered by Codecov. Last update 10c4e8e...5cddaeb. Read the comment docs.
Ideally, the isDevelopmentModeEnabled should be an async function, since the Rocket.Chat server needs to query the database to determine if it is "in development mode". It may seem that it is not needed because currently Meteor "solves" the async problem with its Fibers - but we should not rely on Meteor's features so tightly (if we ever decide to remove it, we should be prepared).
The problem is that the isDevelopmentModeEnable method is called during toStorageEntry which right now is a sync method, and changing so would incur a breaking change.
One of the possibilities would be to allow the console.log to be executed asynchronously. without waiting for it; it's not that important anyway. i.e.:
public static toStorageEntry(appId: string, logger: AppConsole): ILoggerStorageEntry {
const entries = logger.getEntries();
logger.isDevelopmentModeEnabled().then(shouldLog => shouldLog && entries.forEach(({ severity, args }) => console.log(`[${ severity.toUpperCase() }] ${ appId } `, args.join(' '))));
return { ... };
}
But it does look rather strange.
What do you think @lolimay?