Giter VIP home page Giter VIP logo

lumberjack's Introduction

Chop and cut Angular logs like a professional lumberjack.

Logo by Felipe Zambrano

MIT commitizen PRs styled with prettier All Contributors ngworker Wallaby.js

Lines of Code Coverage Duplicated Lines (%)
Quality Gate Status Security Rating Reliability Rating Maintainability Rating

Lumberjack is a versatile Angular logging library, specifically designed to be extended and customized. It provides a few simple log drivers (logging mechanisms, transports, log drivers) out-of-the-box. It's easy to enable the built-in log drivers or create and use custom log drivers.

For support, please refer to the #lumberjack channel in the NgWorkers Discord server.

Features

  • ✅ Configurable multilevel logging
  • ✅ Plugin-based log driver architecture
  • ✅ Robust error handling
  • ✅ Console driver
  • ✅ HTTP driver
  • ✅ Logger base class
  • ✅ Lumberjack service
  • ✅ Best practices guide

Installation

Lumberjack is published as the @ngworker/lumberjack package.

Toolchain Command
NPM CLI npm install @ngworker/lumberjack
PNPM CLI pnpm add @ngworker/lumberjack
Yarn CLI yarn add @ngworker/lumberjack

Documentation

Get access to the full documentation

Wallaby.js

Wallaby.js

Contributors to this repository are welcome to use the Wallaby.js OSS License to get test results immediately as you type, and see the results in your editor right next to your code.

Contributors

Thanks goes to these wonderful people (emoji key):

Nacho Vazquez
Nacho Vazquez

🐛 💻 📖 💡 🤔 🧑‍🏫 🚧 📆 👀 ⚠️ 🔧 📓
Lars Gyrup Brink Nielsen
Lars Gyrup Brink Nielsen

🐛 💻 📖 💡 🤔 🧑‍🏫 🚧 📆 👀 ⚠️ 🔧 📓
Santosh Yadav
Santosh Yadav

💻 📖 💡 🚇 🔌 ⚠️
Dzhavat Ushev
Dzhavat Ushev

📖
Alex Okrushko
Alex Okrushko

💻 🤔 🧑‍🏫 🔬 💻
Bitcollage
Bitcollage

🐛 💻 📖 🤔 📦 👀 ⚠️ 🔧
Arthur Groupp
Arthur Groupp

🤔
Serg
Serg

📖
Sumit Parakh
Sumit Parakh

💻
vimal patel
vimal patel

💻
Ajit Panigrahi
Ajit Panigrahi

📖
Pierre Bouillon
Pierre Bouillon

🤔 ⚠️ 📖 💻
Diego Julião
Diego Julião

🤔 💻

This project follows the all-contributors specification. Contributions of any kind welcome!

lumberjack's People

Contributors

ajitzero avatar allcontributors[bot] avatar dzhavat avatar layzeedk avatar nachovazquez avatar patelvimal avatar santoshyadavdev avatar sumitparakh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

lumberjack's Issues

feat: add test log driver

Add a log driver that can be provided in tests and used for expectations or assertions about logs.

Note: Must not depend on Jasmine or any other test framework.

Migrate to Nx 16.7 and Angular 16.2

What is the motivation/use case for changing the behavior?

We want to at least have one release per major version of Angular. See #188

Describe the solution you'd like

Run the necessary migrations to upgrade to the latest version of Nx and Angular 16.x.

feat: try to add Angular 8.x support

  • Use parallel builds to support Angular v8
  • Publish as separate NPM package, for example @ngworker/lumberjack-view-engine?

Only one compiler flag needs to be turned off for v8 support. Something with closure compiler annotations. Depends on whether we can downgrade to TypeScript 3.4 in at least the app and e2e CI jobs. Manual verification of e2e-schematics.

Create DEV publication to cross post release notes blog posts

What is the motivation/use case for changing the behavior?

We want to reach a bigger audience with the release of blog posts.

For that, we would like to cross-post to the DEV platform.

Describe the solution you'd like

Create a publication in DEV with our brand.

Additional context

#188

Create release notes blog post for Lumberjack 17

What is the motivation/use case for changing the behavior?

Notify the community of the changes coming in v17

Describe the solution you'd like

  • Announce the migrations to Nx and Angular 17. x
  • Describe the implementation of string literal unions for Lumberjack levels
  • Announce deprecation of Enums for log levels and its removal on version 19.

Additional context

#188

Failed to use lumberjack for angular 16

Describe the bug

lumberjack cannot be used together with angular 16

To Reproduce

  1. run 'npm install'
  2. console shows errors
could not resolve dependency:
peer: @angular/core@"^15.0.1" from @ngworker/[email protected]

Expected behavior

lumberjack should be installed and usable

Environment

  • Lumberjack Version 15.0.1
  • Angular version: 16.1.7

see the following excerpt from our 'package.json'

  "dependencies": {
    "@angular/animations": "16.1.7",
    "@angular/cdk": "16.1.6",
    "@angular/common": "16.1.7",
    "@angular/compiler": "16.1.7",
    "@angular/core": "16.1.7",
    "@angular/forms": "16.1.7",
    "@angular/platform-browser": "16.1.7",
    "@angular/platform-browser-dynamic": "16.1.7",
    "@angular/router": "16.1.7",
   
  },
  "devDependencies": {
    "@angular-builders/custom-webpack": "16.0.0",
    "@angular-devkit/build-angular": "16.0.0",
    "@angular-devkit/core": "16.1.6",
    "@angular-devkit/schematics": "16.1.6",
    "@angular-eslint/eslint-plugin": "16.0.3",
    "@angular-eslint/eslint-plugin-template": "16.0.3",
    "@angular-eslint/template-parser": "16.0.3",
    "@angular/cli": "~16.1.0",
    "@angular/compiler-cli": "16.1.7",
    "@angular/language-service": "16.1.7",

Add support for String Literal Unions in addition to enums for Lumberjack Levels

What is the motivation/use case for changing the behavior?

We want to remove TypeScript Enums and replace them with TypeScript string literal unions.

Describe the solution you'd like

  • Add support for string literal unions along with the current Enums
  • Deprecate current Enums and notify that they will be released on version 19

Describe alternatives you've considered

Replace the enums in one movement without deprecation. This might be necessary if supporting enums and string literal unions becomes too complex.

Additional context

#188

Migrate all TypeScript private properties to JavaScript private properties (#)

The Problem

Most private properties of the project are using the Typescript private indicator instead of the native ES private properties (#).

ESLint private properties are better for libraries since they actually prohibit consumers from accessing the properties, even at runtime. This prevents unwanted dependencies on library internals.

Acceptance Criteria

Migrate all Typescript private properties to ESLint private properties.

ci: support version strategy for partial Ivy compilation

Angular CLI >=13.0 only allows to partially Ivy compile Angular library bundles, that is these Angular CLI versions cannot build View Engine-compatible library bundles.

A few major Angular CLI versions from now (currently at Angular 13 at the time of writing), the Angular Compatibility Compiler will be removed and only the Angular Linker will remain, removing any support for View Engine-compatible Angular libraries.

We need something like the following:

  • Version 2.x with support for Angular versions 9 through <last major version with NGCC>
  • Version 3.x with support for Angular versions 12.2 through <last major versions without breaking changes in the partially compiled Angular Package Format (APM)>

Option A

  • Features and patches are released across both versions 2.x and 3.x.

Option B

  • Version 2.x is left as-is in a branch with the possibility of hotfix patches.
  • Features are released to version 3.x only.

feature request/refactor: use the `inject` function for dependencies

inject is more type-safe and should give no issue unless a class is created using its constructor instead of TestBed in test.

inject is better for base classes such as LumberjackLogger and ScopedLumberjackLogger to allow sub-classes to add their own dependencies to their constructor without having to pass the base class' dependencies if they so prefer.

Support for implicit contextual parameters

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report
[ ] Performance issue
[x] Feature request
[ ] Documentation issue or request
[ ] Support request
[ ] Other... Please describe:

Current behavior

The logger requires explicit parameters.

Expected behavior

Having the ability for logs to be augmented with implicit contextual information, e.g.:

interface ContextualInformationResolver {
  resolveContextualInformation(): Promise<Record<string, unknown>>;
}

@Injectable({
  providedIn: 'root'
})
class MyContextualInformationResolver implements ContextualInformationResolver {
  async resolveContextualInformation(): Promise<Record<string, unknown>> {
    return {
      // context
    };
  }
}

The contextual information would not used in the log message itself but rather as a separate context (that could still be used when formatting the log though, just like a timestamp).

Minimal reproduction of the problem with instructions

n/a

What is the motivation / use case for changing the behavior?

There is often information that would be useful to see with a log message but is not readily available where the message is logged (not to mention it could lose some of its structure if passed in the message itself).

Typical use cases would be:

  • a correlation identifier
  • a span/parent identifier
  • (not relevant if the library is only used on the front-end) a user identifier, a tenant identifier, etc.

This can make it much easier to filter logs based on such information without having to pass it manually each time a log is created in the user code.

Some examples:

Moreover, most protocols/tools related to logging support passing such contextual information (e.g. Logstash, Kibana, etc.).

Environment

n/a

feat: Filter drivers at log level

This feature should allow Lumberjack clients to determine which drivers are allowed to handle a specified log.

This can be achieved using the driver identifier and it is complementary to the Drivers filtering by level.

This feature should also allow to configure lazy-loaded driver using forFeature method and overriding the driverIdentifier.

ci: publish npm package on tag

Create a new CI workflow that gets triggered on tag push.

  • Run all code quality tests
  • Build the library (and copy README file)
  • publish the npm package with (unknown tag)
  • add the next tag if the release contains beta/ rc text (validate tag format) or latest tag if doesn't.
  • remove the unknown tag.

docs: create Lumberjack documentation website

The Problem

Lumberjack doesn't have a proper documentation website.

The Goal

Create a Lumberjack documentation website like the spectacular one.

Tasks

  • Create and configure Docusaurus documentation website
  • Deploy to Github Pages
  • Configure CI/CD
  • Write proper documentation using the tools format

chore: update to Angular 13

The Problem

The lumberjack project is lagging behind in its Angular version. Currently, it is in version 11.

This will be necessary to start supporting partial Ivy compilation.

The Goals

Convert the Lumberjack repository to the latest version of Angular.

Tasks

  • Migrate to the latest version of Angular, TypeScript, RxJS, and Zone.js
  • Migrate to a compatible version of Jest
  • Migrate Schematics to a compatible version
  • Verify that sonar works by introducing a lint error

feat: support for updating a drivers log configuration at runtime

What is the motivation/use case for changing the behaviour?

I want to update the log levels at runtime to capture additional information for specific users of my application. This is useful when trying to debug an issue affecting a specific user without having to enable logging for all users or requiring the specific user to restart their application.

Describe the solution you'd like

A method to update a log driver's config at runtime - currently config is readonly.

Describe alternatives you've considered

  • Wrapping the logger and implementing my own filtering of the logs based on this dynamic log-level configuration
  • Creating a composite log driver, which creates and filters logs to the underlying drivers accordingly.

Additional context

create-lumberjack-driver package

Alternative to/replacement for the lumberjack-custom-driver template repository.

Migrate to an Nx workspace to implement and test the Nx generators/preset required for this.

feat: Allow LumberjackLogger methods override TPayload parameter

Note: This behavior should be implemented if there is a well-represented need by users of this feature.

Implementing this feature allows using a different payload type or no payload at all in situations where a LumberjackLogger or LumberjackService was injected using a specified generic TPayload parameter.

Example of implementation

 protected createCriticalLogger<TCustomPayload extends TPayload | void = TPayload>(
    message: string
  ): LumberjackLoggerBuilder<TCustomPayload> {
    return this.createLoggerBuilder(LumberjackLevel.Critical, message);
  }

Batching Log Message Requests to the server from the Lumberjack Http Driver

Is there a possible way to queue up the POST requests and send them to the server as batches? How can this be implemented in the current LumberjackHttpDriver

From how I see it, the current approach for this would be collecting the logs entries in a buffer and sending them upon reaching the maxBufferSize or flushing them on timeout if it doesn't reach the maxBufferSize. Is this something that is implementable with the Lumberjack Http Driver, and if not, how to approach this?

feat(schematics) logger generation schematic

The Problem

Custom Loggers are the recommended way of creating logs with Lumberjack, however creating custom Loggers requires a bit of boilerplate.

The Goal

Create schematics generators to create the Custom Loggers boilerplate for us.

Tasks

  • Generate logger extending LumberjackLogger
  • Generate logger extending ScopedLumberjackLogger (--scope=<scope-property-value>)

fix(ci): lumberjack CI/CD

The Problem

The Lumberjack CI workflow is failing because of some breaking changes with the ts-jest. This blocks us from verifying the validity of any PR.

The Goal

Return the CI workflow to successful status checks.

Automate Lumberjack releases

The Problem

Currently, the release of the new Lumberjack version is a manual and tedious task.

The Goal

Automate the release of new versions using GH Actions.

Deprecate NgModules in favor of the Standalone provider functions API

What is the motivation/use case for changing the behavior?

Standalone provider functions have become the standard and recommended way to write Angular applications.

Lumberjack supports both APIs which increases the bundle size.

Describe the solution you'd like

Mark the Lumberjack NgModules as deprecated and notify that they will be removed in version 18.

Additional context

See #188

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.