apache / cordova-discuss

Discussions on features and the future
19 stars 28 forks source link

Proposal: Unified logging #14

Closed daserge closed 8 years ago

daserge commented 9 years ago

Cordova unified logging

Note: The issue is associated with Cordova-lib refactoring proposal .

Existing architecture issues and proposed solutions

1. cordova-lib and cordova platforms have logging set up inconsistently

Current implementation details:

This leads to the following issue: log level of cordova-cli doesn't affect platforms at all.

Proposed solutions:
Variant A: Platforms can use EventEmitter passed as a dependency module via PlatformApi' interface (f.e. as a ctor parameter).
In case of CLI-mode cordova-lib EventEmitter will be used (and logs handling will be unified therefore).
In case of platform-standalone mode EventEmitter will be defaulted in the platform.
Variant B: Pass logger class from cordova-lib down to platforms and call its methods further.

Variant A is recommended as it separates aspects of events emitting from logging and is more flexible in terms of substituting logger module.


2. The log messages aren't standardized

Proposed solution:


3. Platforms logging mechanism does not allow plugging in a custom handling code/module (integration & custom transport levels)

Proposed solution:


4. Errors from third-party components (ant, gradle, etc.) can't be easily distinguished

Proposed solution: Attach to process.spawn stdout and stderr, supply caught errors with their source in meta object (f.e. extended CordovaError - see 2.).

stevengill commented 9 years ago

Great writeup! I've been wanting to look at our logging support and standardizing it across our projects.

I like variant A and the idea that can try out different loggers.

I also like the idea of having error codes we define/standardize and use for cordova that persist among our various projects.

muratsu commented 9 years ago

:+1: I'm all in for a standardized logging. Error verbosity will also give us the ability to debug things much more efficiently. This will make verbose mode much more useful.

nikhilkh commented 9 years ago

This is great! I like variant A.

purplecabbage commented 9 years ago

+1 Variant A

nikhilkh commented 8 years ago

Looks like most of this is implemented now. We should close this issue.