GithubHelp home page GithubHelp logo

darekf77 / ng2-logger Goto Github PK

View Code? Open in Web Editor NEW
60.0 4.0 17.0 8.68 MB

Isomorphic logger for Browser and NodeJS, ( typescript / javascript ) apps

License: MIT License

TypeScript 66.29% JavaScript 14.68% HTML 18.88% CSS 0.14%
logger isomorphic nodejs-library browser typescript ready-for-angular7 ready-for-react ready-for-vue

ng2-logger's Introduction

firedev-logger (ng2-logger)

  • Part of firedev.io
  • Isomorphic Logger for TypeScript and JavaScript apps.
  • Purpose:
    • usefull/elegant backend/frontend logger

You can use this logger in your apps with any TS/JS framework.

See what is going on in your app!

Now chrome console logs are full of colors!

Modules marked

See nice server logs:

Modules marked

To install package run:

npm install ng2-logger --save

First import proper version for your environment:

Nodejs server (or any firedev's lib/app):

import { Log, Level } from  'ng2-logger'

or Browser:

import { Log, Level } from  'ng2-logger/browser'  // new javascript module: es2015 + esnext + angular ivy support

Simple use:

In your file with log:

const  log  =  Log.create('books');

or if you wanna just log errors and warnings :

const  log  =  Log.create('books', Level.ERROR, Level.WARN);

'books' is current class or anything inside .ts/.js file.

You can also assign static color to specific module in application (browser for now only):

log.color  =  'red';

After inited log you are able to start debugging:

log.d('object',obj) // console.log

log.er('object',obj) // console.error

log.i('object',obj) // console.info

log.w('object',obj) // console.warn

or

log.debug('object',obj) // console.log

log.error('object',obj) // console.error

log.info('object',obj) // console.info

log.warn('object',obj) // console.warn

Production mode


You will not see anyting in prduction mode:

// enable production mode in your app

...

Log.setProductionMode();

...

// your app code with console and ng2-logger logs

It is important to set production mode before any log messages are executed.

This will ensure that log messages that should not be seen are leaked out.

Selective debug - global settings


Optional specify what you wanna see in yours debug console.

This settings will override settings from files.

Log.setProductionMode();

Log.onlyModules('src:books', 'src:records', 'src:page:login');

Log.onlyLevel(Level.ERROR,Level.INFO);

Specifying onlyModules as regular expression(s)


In the above example you'll notice module:books and module:records were specified.

you might be using such syntax for namespace hierarchy etc. You may also pass in one or more regular

expression string(s) to the onlyModule function to specify a selection of modules you wish

to show, for instances those whose name begins with src:

  

Log.onlyModules( new  RegEx('^.src') );

ng2-logger's People

Contributors

adrprado avatar darekf77 avatar darekf77igt avatar gerritk avatar zbicin 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

Watchers

 avatar  avatar  avatar  avatar

ng2-logger's Issues

'ReferenceError: global is not defined' with 3.0.13

After updating to 3.0.13, I am getting a new error when the Logger is initialized. FYI: I'm using the latest Angular 10.1.1 and Typescript 4.0.2.

ERROR Error: Uncaught (in promise): ReferenceError: global is not defined ReferenceError: global is not defined
at msg (display.js:41) at Logger._data (logger.js:144) at Logger.data (logger.js:82) at Logger.debug (logger.ts:39) at new AppGuard (app.guard.ts:20) at Object.AppGuard_Factory [as factory] (app.guard.ts:57) at R3Injector.hydrate (core.js:11242) at R3Injector.get (core.js:11064) at NgModuleRef$1.get (core.js:24194) at getToken (router.js:2672) at resolvePromise (zone.js:1215) at resolvePromise (zone.js:1165) at zone.js:1277 at ZoneDelegate.invokeTask (zone.js:407) at Object.onInvokeTask (core.js:27419) at ZoneDelegate.invokeTask (zone.js:406) at Zone.runTask (zone.js:179) at drainMicroTaskQueue (zone.js:583)

Error loading in IE 11

Hello.

I have used ng2-logger in my project. It works fine in all browsers, but when try to load it in Explorer 11 the console gives me a SCRIPT1002: Syntax Error, and the line point to the log.js file, and the bundled line:

eval("\nObject.defineProperty(exports, \"__esModule\", { value: true });\nconst logger_1 = __webpack_require__(\"../../../../ng2-logger/logger.js\");\nconst level_1 = __webpack_require__(\"../../../../ng2-logger/level.js\");\nconst display_1 = __webpack_require__(\"../../../../ng2-logger/display.js\");\nconst include_1 = __webpack_require__(\"../../../../ng2-logger/include.js\");\nconst helper_1 = __webpack_require__(\"../../../../ng2-logger/helper.js\");\nif (helper_1.isNode) {\n  var randomcolor = __webpack_require__(\"../../../../randomcolor/randomColor.js\");\n}\nclass Log {\n  static create(name, ...level) {\n    let i;\n    if (Log.instances[name] === undefined) {\n      i = new logger_1.Logger(name, Log.getRandomColor(), Log.isDevelopmentMode, level, Log.isMutedModule(name), Log.levels.length > 0 ? Log.fixedWidth : undefined, Log.levels.length > 0 ? Log.display : undefined);\n      Log.instances[name] = i;\n    }\n    else {\n      i = Log.instances[name];\n    }\n    return i;\n  }\n  static getRandomColor() {\n    if (helper_1.isNode) {\n      return randomcolor({ luminosity: 'light', count: 10 });\n    }\n    let letters = '012345'.split('');\n    let color = '#';\n    color += letters[Math.round(Math.random() * 5)];\n    letters = '0123456789ABCDEF'.split('');\n    for (let i = 0; i < 5; i++) {\n      color += letters[Math.round(Math.random() * 15)];\n    }\n    if (color === undefined)\n      return this.getRandomColor();\n    return color;\n  }\n  static display(name, data, incomming, moduleName) {\n    if (!include_1.contain(Log.levels, incomming))\n      return;\n    if (incomming === level_1.Level.DATA) {\n      display_1.Display.msg(name, data, name, Log.instances[moduleName].color, level_1.Level.DATA, Log.instances[moduleName].fixedWidth);\n    }\n    if (incomming === level_1.Level.ERROR) {\n      display_1.Display.msg(name, data, name, Log.instances[moduleName].color, level_1.Level.ERROR, Log.instances[moduleName].fixedWidth);\n    }\n    if (incomming === level_1.Level.INFO) {\n      display_1.Display.msg(name, data, name, Log.instances[moduleName].color, level_1.Level.INFO, Log.instances[moduleName].fixedWidth);\n    }\n    if (incomming === level_1.Level.WARN) {\n      display_1.Display.msg(name, data, name, Log.instances[moduleName].color, level_1.Level.WARN, Log.instances[moduleName].fixedWidth);\n    }\n  }\n  static onlyLevel(...level) {\n    if (Log._logOnly) {\n      console.error('You should use funcion onlyLevel only once');\n      return;\n    }\n    if (Log._logOnly)\n      Log._logOnly = true;\n    if (level.length === 0)\n      return;\n    Log.levels = level;\n  }\n  static onlyModules(...modules) {\n    if (Log._logModules) {\n      console.error('You should use funcion onlyModules only once');\n      return;\n    }\n    if (modules.length === 0)\n      return;\n    Log.modules = modules;\n    Log.muteAllOtherModules();\n  }\n  static isMutedModule(moduleName) {\n    if (Log.modules.length == 0)\n      return false;\n    if (!include_1.contain(Log.modules, moduleName))\n      return true;\n    return false;\n  }\n  static muteAllOtherModules() {\n    for (var moduleName in Log.instances) {\n      if (!include_1.contain(Log.modules, moduleName))\n        Log.instances[moduleName].mute();\n    }\n  }\n  static setProductionMode() {\n    if (Log.modeIsSet) {\n      console.error('Mode is already set');\n      return;\n    }\n    if (console !== undefined && console.clear !== undefined) {\n      setTimeout(() => {\n        console.clear();\n        console.log = () => { };\n        console.error = () => { };\n        console.warn = () => { };\n        console.info = () => { };\n      });\n    }\n    logger_1.Logger.isProductionMode = true;\n    Log.isDevelopmentMode = false;\n  }\n}\nLog.instances = {};\nLog.fixedWidth = 0;\nLog._logOnly = false;\nLog.levels = [];\nLog._logModules = false;\nLog.modules = [];\nLog.isDevelopmentMode = true;\nLog.modeIsSet = false;\nexports.Log = Log;\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIkM6L1VzZXJzL1JpY2FyZG8vUHJveWVjdG9zL253ZS9ud2UtYW5ndWxhci9ub2RlX21vZHVsZXMvbmcyLWxvZ2dlci9sb2cuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7QUFDQSw4Q0FBOEMsY0FBYztBQUM1RDtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBLDBCQUEwQixpQ0F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xuICAgIH1cbiAgICBsb2dnZXJfMS5Mb2dnZXIuaXNQcm9kdWN0aW9uTW9kZSA9IHRydWU7XG4gICAgTG9nLmlzRGV2ZWxvcG1lbnRNb2RlID0gZmFsc2U7XG4gIH1cbn1cbkxvZy5pbnN0YW5jZXMgPSB7fTtcbkxvZy5maXhlZFdpZHRoID0gMDtcbkxvZy5fbG9nT25seSA9IGZhbHNlO1xuTG9nLmxldmVscyA9IFtdO1xuTG9nLl9sb2dNb2R1bGVzID0gZmFsc2U7XG5Mb2cubW9kdWxlcyA9IFtdO1xuTG9nLmlzRGV2ZWxvcG1lbnRNb2RlID0gdHJ1ZTtcbkxvZy5tb2RlSXNTZXQgPSBmYWxzZTtcbmV4cG9ydHMuTG9nID0gTG9nO1xuXG5cblxuLy8vLy8vLy8vLy8vLy8vLy8vXG4vLyBXRUJQQUNLIEZPT1RFUlxuLy8gQzovVXNlcnMvUmljYXJkby9Qcm95ZWN0b3MvbndlL253ZS1hbmd1bGFyL25vZGVfbW9kdWxlcy9uZzItbG9nZ2VyL2xvZy5qc1xuLy8gbW9kdWxlIGlkID0gLi4vLi4vLi4vLi4vbmcyLWxvZ2dlci9sb2cuanNcbi8vIG1vZHVsZSBjaHVua3MgPSB2ZW5kb3IiXSwic291cmNlUm9vdCI6IndlYnBhY2s6Ly8vIn0=\n//# sourceURL=webpack-internal:///../../../../ng2-logger/log.js\n");

I have been doing lots of test, and tried to fix it, but cannot get the fix for the error. Any Idea or help?

I am using all polyfills from angular 5.2.

Thanks.

Angular Package Spec

The modules does not follow the Angular module spec (https://docs.google.com/document/d/1CZC2rcpxffTDfRDs6p1cfbmKNLA6x5O-NtkJglDaBVs/preview).

One aspect that spec mandates is that the module should be available as es5. I think that's true for the ng2-logger itself but not for the chalk dependency.
As a consequence an application using this lib and compiling to es5 (then using webpack to create the bundle) will not be es5 compatible. That in turn is a problem for the crawlability of the resulting app, i.e. the google crawler will not be able to crawl the application.

Would it be possible to create a bundle according to the angular module spec (e.g. using ng-packagr)?

with .43 the client import is broken

I get the usual error fs not found for node_modules backend.js for ng2-logger but I am not using that at ll. I am importing only the client module

Add Logger to index

Hello.

I'm trying to use ng2-logger (v2.0.26) in a personal library, but each time I try to compile it with Rollup I get this error:

error TS4029: Public property 'log' of exported class has or is using name 'Logger' from external module "[...]/node_modules/ng2-logger/logger" but cannot be named.

I tried adding export * from './logger'; to index.d.ts and __export(require("./logger")); to index.js and it all worked.

Thanks a lot for the library.

Feature: Stack traces

Following the Console Web Api the stack trace function is missing

function foo() {
  function bar() {
    console.trace();
  }
  bar();
}

foo();

Fixed width for labels

Hello Dariusz,

I'm using your logger on the third project already, it is awesome, thank you.
I made a little enhancement for better usability (screenshot), fixed width for labels:

image

Pretty simple configuration:

import { Log, Level } from 'ng2-logger/ng2-logger'
const log = Log.create('AppCmp')
log.color = 'orange'
log.fixedWidth = 30 // width of the label (amount of chars, spaces)

Ping me if you'll be interested in the code, I can make a pull request.

Log levels are optimized away in ng6 build

I noticed that when using this library in an Angular 6 project, this code:

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Level;
(function (Level) {
    Level[Level["DATA"] = 0] = "DATA";
    Level[Level["INFO"] = 1] = "INFO";
    Level[Level["WARN"] = 2] = "WARN";
    Level[Level["ERROR"] = 3] = "ERROR";
    Level[Level["__NOTHING"] = 4] = "__NOTHING";
})(Level = exports.Level || (exports.Level = {}));
//# sourceMappingURL=level.js.map

is NOT part of my application bundle, the optimizer seems to remove it as a side effect (https://github.com/webpack/webpack/tree/master/examples/side-effects).

Would it be possible to provide a side effects free bundle (see webpack v4 "sideEffects": false in webpack https://goo.gl/jB3GVv).

It might be as simple as recompiling the bundle with ng-packagr using the latest libraries.

Feature: Table

Following the Console Web Api the table function is missing

// an array of strings
console.table(["apples", "oranges", "bananas"]);

From 3.x.x to 4.x.x download old deps

When i want to upgrade form 3 to 4, its download too many old and deprecated deps
also its try to run node gyp by python,

install log

Upgrading .../package.json
[====================] 129/129 100%

 ng2-logger  ~3.0.14  →  ~4.0.3   

Run npm install to install new versions.

stano@stano-NUC:~/projects/docker/cross-sandbox$ npm install
npm WARN using --force I sure hope you know what you are doing.
npm WARN deprecated @angular/[email protected]: Package no longer supported. Use @angular/common instead, see https://angular.io/guide/deprecations#angularhttp
npm WARN deprecated @types/[email protected]: This is a stub types definition. chokidar provides its own type definitions, so you do not need this installed.
npm WARN deprecated [email protected]: CircularJSON is in maintenance only, flatted is its successor.
npm WARN deprecated [email protected]: Library moved to @circlon/angular-tree-component
npm WARN deprecated @types/[email protected]: This is a stub types definition. systeminformation provides its own type definitions, so you do not need this installed.
npm WARN deprecated [email protected]: Please upgrade express-fileupload to version 1.1.8+ due to a security vulnerability with the parseNested option
npm WARN deprecated [email protected]: gulp-util is deprecated - replace it, following the guidelines at https://medium.com/gulpjs/gulp-util-ca3b1f9f9ac5
npm WARN deprecated [email protected]: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)
npm WARN deprecated [email protected]: This package has been deprecated and is no longer maintained. Please use @rollup/plugin-commonjs.
npm WARN deprecated [email protected]: This package has been deprecated and is no longer maintained. Please use @rollup/plugin-node-resolve.
npm WARN deprecated [email protected]: This module has been deprecated and is no longer maintained. Please use @rollup/plugin-json.
npm WARN deprecated [email protected]: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
npm WARN deprecated [email protected]: Please upgrade to kleur@3 or migrate to 'ansi-colors' if you prefer the old syntax. Visit <https://github.com/lukeed/kleur/releases/tag/v3.0.0\> for migration path(s).
npm WARN deprecated [email protected]: letsencrypt has been renamed to greenlock. Please find it at npm greenlock
npm WARN deprecated [email protected]: Please use the 'safe-timers' module instead
npm WARN deprecated [email protected]: request-promise has been deprecated because it extends the now deprecated request package, see https://github.com/request/request/issues/3142
npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated [email protected]: this package has been deprecated
npm WARN deprecated [email protected]: This module relies on Node.js's internals and will break at some point. Do not use it, and update to [email protected].
npm WARN deprecated [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated [email protected]: cross-spawn no longer requires a build toolchain, use it instead
npm WARN deprecated [email protected]: Use uuid module instead
npm WARN deprecated [email protected]: This module moved to @hapi/hawk. Please make sure to switch over as this distribution is no longer supported and may contain bugs and critical security issues.
npm WARN deprecated [email protected]: this library is no longer supported
npm WARN deprecated [email protected]: core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3.
npm WARN deprecated [email protected]: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
npm WARN deprecated [email protected]: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
npm WARN deprecated [email protected]: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
npm WARN deprecated [email protected]: This module moved to @hapi/sntp. Please make sure to switch over as this distribution is no longer supported and may contain bugs and critical security issues.
npm WARN deprecated [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated [email protected]: please upgrade to graceful-fs 4 for compatibility with current and future versions of Node.js
npm WARN deprecated [email protected]: CircularJSON is in maintenance only, flatted is its successor.
npm WARN deprecated [email protected]: request-promise-native has been deprecated because it extends the now deprecated request package, see https://github.com/request/request/issues/3142

> [email protected] install /home/node/app/node_modules/fibers
> node build.js || nodejs build.js

`linux-x64-83-glibc` exists; testing
Binary is fine; exiting

> [email protected] install /home/node/app/node_modules/cpuid
> (node-gyp rebuild 2> builderror.log) || (exit 0)


> [email protected] install /home/node/app/node_modules/deasync
> node ./build.js

`linux-x64-node-14` exists; testing
Binary is fine; exiting

> [email protected] install /home/node/app/node_modules/sqlite3
> node-pre-gyp install --fallback-to-build

node-pre-gyp WARN Using request for node-pre-gyp https download 
node-pre-gyp WARN Tried to download(403): https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v4.0.9/node-v83-linux-x64.tar.gz 
node-pre-gyp WARN Pre-built binaries not found for [email protected] and [email protected] (node-v83 ABI, glibc) (falling back to source compile with node-gyp) 
gyp ERR! find Python 
gyp ERR! find Python Python is not set from command line or npm configuration
gyp ERR! find Python Python is not set from environment variable PYTHON
gyp ERR! find Python checking if "python" can be used
gyp ERR! find Python - "python" is not in PATH or produced an error
gyp ERR! find Python checking if "python2" can be used
gyp ERR! find Python - "python2" is not in PATH or produced an error
gyp ERR! find Python checking if "python3" can be used
gyp ERR! find Python - "python3" is not in PATH or produced an error
gyp ERR! find Python 
gyp ERR! find Python **********************************************************
gyp ERR! find Python You need to install the latest version of Python.
gyp ERR! find Python Node-gyp should be able to find and use Python. If not,
gyp ERR! find Python you can try one of the following options:
gyp ERR! find Python - Use the switch --python="/path/to/pythonexecutable"
gyp ERR! find Python   (accepted by both node-gyp and npm)
gyp ERR! find Python - Set the environment variable PYTHON
gyp ERR! find Python - Set the npm configuration variable python:
gyp ERR! find Python   npm config set python "/path/to/pythonexecutable"
gyp ERR! find Python For more information consult the documentation at:
gyp ERR! find Python https://github.com/nodejs/node-gyp#installation
gyp ERR! find Python **********************************************************
gyp ERR! find Python 
gyp ERR! configure error 
gyp ERR! stack Error: Could not find any Python installation to use
gyp ERR! stack     at PythonFinder.fail (/home/node/.npm-global/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:307:47)
gyp ERR! stack     at PythonFinder.runChecks (/home/node/.npm-global/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:136:21)
gyp ERR! stack     at PythonFinder.<anonymous> (/home/node/.npm-global/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:179:16)
gyp ERR! stack     at PythonFinder.execFileCallback (/home/node/.npm-global/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:271:16)
gyp ERR! stack     at exithandler (child_process.js:315:5)
gyp ERR! stack     at ChildProcess.errorhandler (child_process.js:327:5)
gyp ERR! stack     at ChildProcess.emit (events.js:314:20)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:274:12)
gyp ERR! stack     at onErrorNT (internal/child_process.js:468:16)
gyp ERR! stack     at processTicksAndRejections (internal/process/task_queues.js:80:21)
gyp ERR! System Linux 5.6.0-1032-oem
gyp ERR! command "/usr/local/bin/node" "/home/node/.npm-global/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/home/node/app/node_modules/sqlite3/lib/binding/node-v83-linux-x64/node_sqlite3.node" "--module_name=node_sqlite3" "--module_path=/home/node/app/node_modules/sqlite3/lib/binding/node-v83-linux-x64" "--napi_version=6" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v83"
gyp ERR! cwd /home/node/app/node_modules/sqlite3
gyp ERR! node -v v14.7.0
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok 
node-pre-gyp ERR! build error 
node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/bin/node /home/node/.npm-global/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/home/node/app/node_modules/sqlite3/lib/binding/node-v83-linux-x64/node_sqlite3.node --module_name=node_sqlite3 --module_path=/home/node/app/node_modules/sqlite3/lib/binding/node-v83-linux-x64 --napi_version=6 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v83' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/home/node/app/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:314:20)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:1051:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:287:5)
node-pre-gyp ERR! System Linux 5.6.0-1032-oem
node-pre-gyp ERR! command "/usr/local/bin/node" "/home/node/app/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /home/node/app/node_modules/sqlite3
node-pre-gyp ERR! node -v v14.7.0
node-pre-gyp ERR! node-pre-gyp -v v0.11.0
node-pre-gyp ERR! not ok 
Failed to execute '/usr/local/bin/node /home/node/.npm-global/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/home/node/app/node_modules/sqlite3/lib/binding/node-v83-linux-x64/node_sqlite3.node --module_name=node_sqlite3 --module_path=/home/node/app/node_modules/sqlite3/lib/binding/node-v83-linux-x64 --napi_version=6 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v83' (1)
npm WARN notsup Unsupported engine for [email protected]: wanted: {"node":"0.10 || 0.12 || 4 || 5 || 6"} (current: {"node":"14.7.0","npm":"6.14.7"})
npm WARN notsup Not compatible with your version of node/npm: [email protected]
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.1.2 (node_modules/morphi/node_modules/rollup/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN notsup Unsupported engine for [email protected]: wanted: {"node":"0.10 || 0.12 || 4 || 5 || 6"} (current: {"node":"14.7.0","npm":"6.14.7"})
npm WARN notsup Not compatible with your version of node/npm: [email protected]
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.1.2 (node_modules/bs4-breakpoint/node_modules/rollup/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^2.0.6 (node_modules/incremental-compiler/node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.1.2 (node_modules/ng-packagr/node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN notsup Unsupported engine for [email protected]: wanted: {"node":"0.10 || 0.12 || 4 || 5 || 6"} (current: {"node":"14.7.0","npm":"6.14.7"})
npm WARN notsup Not compatible with your version of node/npm: [email protected]
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.1.2 (node_modules/tnp-db/node_modules/rollup/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN notsup Unsupported engine for [email protected]: wanted: {"node":"0.10 || 0.12 || 4 || 5 || 6"} (current: {"node":"14.7.0","npm":"6.14.7"})
npm WARN notsup Not compatible with your version of node/npm: [email protected]
npm WARN @agm/[email protected] requires a peer of @angular/common@^6.0.0 || ^7.0.0 || ^8.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @agm/[email protected] requires a peer of @angular/core@^6.0.0 || ^7.0.0 || ^8.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @angular/[email protected] requires a peer of zone.js@~0.10.3 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of eslint@^4.10.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of eslint-plugin-node@^5.2.1 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of eslint-plugin-prettier@^2.3.1 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of eslint-plugin-react@^7.4.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of prettier@^1.7.4 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of @typescript-eslint/parser@^3.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of @typescript-eslint/parser@^3.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of typescript@^3.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of selenium-webdriver@^2.44.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of tsutils@^3.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @angular/[email protected] requires a peer of @angular/[email protected] but none is installed. You must install peer dependencies yourself.
npm WARN @angular/[email protected] requires a peer of @angular/[email protected] but none is installed. You must install peer dependencies yourself.
npm WARN @angular/[email protected] requires a peer of @angular/[email protected] but none is installed. You must install peer dependencies yourself.
npm WARN @angular/[email protected] requires a peer of tslib@^1.9.0 but none is installed. You must install peer dependencies yourself.
npm WARN @angular/[email protected] requires a peer of @angular/[email protected] but none is installed. You must install peer dependencies yourself.
npm WARN @angular/[email protected] requires a peer of @angular/[email protected] but none is installed. You must install peer dependencies yourself.
npm WARN @angular/[email protected] requires a peer of tslib@^1.10.0 but none is installed. You must install peer dependencies yourself.
npm WARN @ngx-formly/[email protected] requires a peer of @ionic/angular@^4.0.0 || ^5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @swimlane/[email protected] requires a peer of @angular/common@<9.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @swimlane/[email protected] requires a peer of @angular/core@<9.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @swimlane/[email protected] requires a peer of @angular/platform-browser@<9.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of core-js@^2.4.1 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of [email protected] - 3 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of popper.js@^1.14.7 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of @angular/compiler@^6.0.0 || ^7.0.0 || ^8.0.0-beta.0 || ^8.1.0-beta.0 || ^8.2.0-beta.0 || ^8.3.0-beta.0 || ^8.4.0-beta.0 || >=9.0.0-beta < 9 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of @angular/compiler-cli@^6.0.0 || ^7.0.0 || ^8.0.0-beta.0 || ^8.1.0-beta.0 || ^8.2.0-beta.0 || ^8.3.0-beta.0 || ^8.4.0-beta.0 || >=9.0.0-beta < 9 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of tslib@^1.9.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of typescript@>=2.7 <3.6 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of @angular/core@>=4.0.0 <5.0.0 || >=4.0.0-beta <5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of @angular/router@>=4.0.0 <5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of @angular/common@^6.1.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of @angular/core@^6.1.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of @angular/forms@^6.1.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of ngx-bootstrap@^3.0.1 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of rxjs@~6.2.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of @angular/common@^8.2.13 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of @angular/core@^8.2.13 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of @angular/forms@^8.2.13 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of tslib@^1.10.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of typescript@>=2.4.2 <2.7 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/@angular-devkit/build-angular/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/@angular/compiler-cli/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/rollup/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/karma/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

npm ERR! Maximum call stack size exceeded

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/node/.npm/_logs/2020-11-04T10_39_05_681Z-debug.log

my package.json

{
  ...
  "dependencies": {
    "@agm/core": "~1.1.0",
    "@angular/animations": "~10.2.1",
    "@angular/cdk": "~10.2.7",
    "@angular/common": "~10.2.1",
    "@angular/compiler": "~10.2.1",
    "@angular/core": "~10.2.1",
    "@angular/forms": "~10.2.1",
    "@angular/localize": "~10.2.1",
    "@angular/platform-browser": "~10.2.1",
    "@angular/platform-browser-dynamic": "~10.2.1",
    "@angular/router": "~10.2.1",
    "@ckeditor/ckeditor5-angular": "^2.0.1",
    "@ckeditor/ckeditor5-build-classic": "github:bart-sk/ckeditor5-build-classic",
    "@ngrx/effects": "~10.0.1",
    "@ngrx/store": "~10.0.1",
    "core-js": "~3.6.5",
    "create-hmac": "~1.1.7",
    "croppie": "~2.6.5",
    "dom-autoscroller": "~2.3.4",
    "dwt": "~16.1.2",
    "file-saver": "~2.0.2",
    "luxon": "~1.25.0",
    "md5": "~2.3.0",
    "moment": "~2.29.1",
    "moment-timezone": "~0.5.31",
    "normalize.css": "~8.0.1",
    "ng2-logger": "~4.0.3",
    "ngx-clipboard": "~14.0.1",
    "node-interval-tree": "~1.3.3",
    "pdfmake": "~0.1.68",
    "perfect-scrollbar": "~1.5.0",
    "resize-observer-polyfill": "~1.5.1",
    "rrule": "~2.6.6",
    "rxjs": "~6.6.3",
    "socket.io-client": "~2.3.1",
    "sortablejs": "~1.12.0",
    "trust1connector": "~3.0.0",
    "tslib": "~2.0.3",
    "xlsx": "~0.16.8",
    "zone.js": "~0.11.3"
  },
  "devDependencies": {
    "@angular-builders/custom-webpack": "~10.0.1",
    "@angular-devkit/build-angular": "~0.1002.0",
    "@angular/cli": "~10.2.0",
    "@angular/compiler-cli": "~10.2.1",
    "@angular/language-service": "~10.2.1",
    "@ngrx/store-devtools": "~10.0.1",
    "@ngtools/webpack": "~10.2.0",
    "@testing-library/angular": "~10.1.3",
    "@testing-library/user-event": "~12.2.0",
    "@types/core-js": "~2.5.4",
    "@types/create-hmac": "~1.1.0",
    "@types/croppie": "~2.5.5",
    "@types/dwt": "~16.1.1",
    "@types/file-saver": "~2.0.1",
    "@types/googlemaps": "~3.40.3",
    "@types/hammerjs": "~2.0.36",
    "@types/jasmine": "~3.6.1",
    "@types/jasminewd2": "~2.0.8",
    "@types/karma": "~5.0.1",
    "@types/lodash-es": "~4.17.3",
    "@types/md5": "~2.2.1",
    "@types/mocha": "~8.0.3",
    "@types/modernizr": "~3.5.3",
    "@types/new-relic-browser": "~0.1118.0",
    "@types/node": "~14.14.6",
    "@types/pdfmake": "~0.1.16",
    "@types/socket.io-client": "~1.4.34",
    "@types/sortablejs": "~1.10.6",
    "@types/svg-sprite-loader": "~3.9.2",
    "@types/terser-webpack-plugin": "~5.0.2",
    "@types/webpack": "~4.41.24",
    "@types/webpack-dev-server": "~3.11.1",
    "@types/webpack-env": "~1.15.3",
    "@types/webpack-merge": "~4.1.5",
    "@types/youtube": "~0.0.39",
    "@typescript-eslint/eslint-plugin": "~4.6.1",
    "@typescript-eslint/parser": "~4.6.1",
    "base64-js": "~1.3.1",
    "browserstack-local": "~1.4.8",
    "chalk": "~4.1.0",
    "codelyzer": "~6.0.1",
    "cross-env": "~7.0.2",
    "eslint": "~7.12.1",
    "eslint-config-prettier": "~6.15.0",
    "eslint-config-unicorn": "~0.5.0",
    "eslint-plugin-ngrx": "~1.10.2",
    "eslint-plugin-prettier": "~3.1.4",
    "eslint-plugin-unicorn": "~23.0.0",
    "husky": "~4.3.0",
    "jasmine": "~3.6.3",
    "jasmine-core": "~3.6.0",
    "jasmine-reporters": "~2.3.2",
    "jasmine-spec-reporter": "~6.0.0",
    "junit": "~1.4.9",
    "karma": "~5.2.3",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage-istanbul-reporter": "~3.0.3",
    "karma-jasmine": "~4.0.1",
    "karma-jasmine-html-reporter": "~1.5.4",
    "karma-junit-reporter": "~2.0.1",
    "karma-mocha-reporter": "~2.2.5",
    "karma-selenium-webdriver-launcher": "~0.0.4",
    "lint-staged": "~10.5.1",
    "lodash-es": "~4.17.15",
    "mobile-detect": "~1.4.4",
    "moment-locales-webpack-plugin": "~1.2.0",
    "moment-timezone-data-webpack-plugin": "~1.3.0",
    "ngx-i18nsupport": "~0.17.1",
    "parallel-webpack": "~3.0.0-alpha.2",
    "prettier": "~2.1.2",
    "prettier-eslint": "~11.0.0",
    "protractor": "~7.0.0",
    "protractor-beautiful-reporter": "~1.3.6",
    "protractor-fail-fast": "~3.1.0",
    "rxjs-tslint-rules": "~4.34.3",
    "sass": "~1.28.0",
    "source-map-support": "~0.5.19",
    "stylelint": "~13.7.2",
    "stylelint-config-prettier": "~8.0.2",
    "stylelint-config-standard": "~20.0.0",
    "svg-sprite-loader": "~5.0.0",
    "svg-transform-loader": "~2.0.13",
    "svgo": "~1.3.2",
    "svgo-loader": "~2.2.1",
    "tslint": "~6.1.3",
    "tslint-config-prettier": "~1.18.0",
    "tslint-jasmine-rules": "~1.6.1",
    "typescript": "~4.0.5",
    "url-loader": "~4.1.1"
  }
}

Warnings from ng9 build

When pulling in the browser version of ng2-logger in an ng9 ivy build I get this warning:

WARNING in Entry point '@acoustic-content-sdk/ng-logger' contains deep imports into '/usr/build/sites/node_modules/ng2-logger/browser'. This is probably not a problem, but may cause the compilation of entry points to be out of order.

I think this is because ng2-logger/browser does not contain its own package.json file. Could you consider representing ng2-logger/browser using a secondary entry point instead of having to use deep imports?

https://github.com/ng-packagr/ng-packagr/blob/master/docs/secondary-entrypoints.md

Feature: Group

Following the Console Web Api the group functions are missing

console.log("This is the outer level");
console.group();
console.log("Level 2");
console.group();
console.log("Level 3");
console.warn("More of level 3");
console.groupEnd();
console.log("Back to level 2");
console.groupEnd();
console.log("Back to the outer level");
console.groupCollapsed([label]);
console.groupEnd();

ng lint errors with angular cli 1.0.0

Hello,
with angular cli 1.0.0 ng lint returns some "errors":

[...]/node_modules/ng2-logger/src/display.ts[10, 9]: if statements must be braced
[...]/node_modules/ng2-logger/src/display.ts[11, 9]: if statements must be braced
[...]/node_modules/ng2-logger/src/display.ts[12, 9]: if statements must be braced
[...]/node_modules/ng2-logger/src/display.ts[14, 13]: Identifier 'a1' is never reassigned; use 'const' instead of 'let'.
[...]/node_modules/ng2-logger/src/display.ts[15, 13]: Identifier 'a2' is never reassigned; use 'const' instead of 'let'.
[...]/node_modules/ng2-logger/src/display.ts[16, 13]: Identifier 'a3' is never reassigned; use 'const' instead of 'let'.
[...]/node_modules/ng2-logger/src/logger.ts[18, 9]: if statements must be braced
[...]/node_modules/ng2-logger/src/logger.ts[20, 9]: if statements must be braced
[...]/node_modules/ng2-logger/src/logger.ts[21, 9]: if statements must be braced
[...]/node_modules/ng2-logger/src/logger.ts[29, 9]: if statements must be braced
[...]/node_modules/ng2-logger/src/logger.ts[31, 9]: if statements must be braced
[...]/node_modules/ng2-logger/src/logger.ts[32, 9]: if statements must be braced
[...]/node_modules/ng2-logger/src/logger.ts[40, 9]: if statements must be braced
[...]/node_modules/ng2-logger/src/logger.ts[42, 9]: if statements must be braced
[...]/node_modules/ng2-logger/src/logger.ts[43, 9]: if statements must be braced
[...]/node_modules/ng2-logger/src/logger.ts[51, 9]: if statements must be braced
[...]/node_modules/ng2-logger/src/logger.ts[53, 9]: if statements must be braced
[...]/node_modules/ng2-logger/src/logger.ts[54, 9]: if statements must be braced
[...]/node_modules/ng2-logger/src/logger.ts[63, 9]: if statements must be braced
[...]/node_modules/ng2-logger/src/logger.ts[64, 9]: if statements must be braced
[...]/node_modules/ng2-logger/src/logger.ts[66, 9]: if statements must be braced
[...]/node_modules/ng2-logger/src/logger.ts[67, 9]: if statements must be braced
[...]/node_modules/ng2-logger/src/logger.ts[74, 5]: Declaration of instance field not allowed after declaration of instance method. Instead, this should come after static fields.
[...]/node_modules/ng2-logger/src/logger.ts[80, 5]: Declaration of static field not allowed after declaration of instance method. Instead, this should come at the beginning of the class/interface.
[...]/node_modules/ng2-logger/src/logger.ts[80, 37]: Type boolean trivially inferred from a boolean literal, remove type annotation
[...]/node_modules/ng2-logger/src/logger.ts[62, 5]: misplaced opening brace
[...]/node_modules/ng2-logger/src/logger.ts[61, 30]: missing whitespace
[...]/node_modules/ng2-logger/src/logger.ts[61, 44]: missing whitespace
[...]/node_modules/ng2-logger/src/logger.ts[61, 59]: missing whitespace
[...]/node_modules/ng2-logger/src/log.ts[37, 9]: if statements must be braced
[...]/node_modules/ng2-logger/src/log.ts[42, 9]: if statements must be braced
[...]/node_modules/ng2-logger/src/log.ts[64, 9]: if statements must be braced
[...]/node_modules/ng2-logger/src/log.ts[65, 9]: if statements must be braced
[...]/node_modules/ng2-logger/src/log.ts[76, 9]: if statements must be braced
[...]/node_modules/ng2-logger/src/log.ts[81, 9]: if statements must be braced
[...]/node_modules/ng2-logger/src/log.ts[82, 9]: if statements must be braced
[...]/node_modules/ng2-logger/src/log.ts[87, 13]: if statements must be braced
[...]/node_modules/ng2-logger/src/log.ts[57, 5]: Declaration of static field not allowed after declaration of static method. Instead, this should come at the beginning of the class/interface.
[...]/node_modules/ng2-logger/src/log.ts[58, 5]: Declaration of static field not allowed after declaration of static method. Instead, this should come at the beginning of the class/interface.
[...]/node_modules/ng2-logger/src/log.ts[69, 5]: Declaration of static field not allowed after declaration of static method. Instead, this should come at the beginning of the class/interface.
[...]/node_modules/ng2-logger/src/log.ts[70, 5]: Declaration of static field not allowed after declaration of static method. Instead, this should come at the beginning of the class/interface.
[...]/node_modules/ng2-logger/src/log.ts[92, 5]: Declaration of static field not allowed after declaration of static method. Instead, this should come at the beginning of the class/interface.
[...]/node_modules/ng2-logger/src/log.ts[93, 5]: Declaration of static field not allowed after declaration of static method. Instead, this should come at the beginning of the class/interface.
[...]/node_modules/ng2-logger/src/log.ts[93, 31]: Type boolean trivially inferred from a boolean literal, remove type annotation
[...]/node_modules/ng2-logger/src/log.ts[86, 14]: Forbidden 'var' keyword, use 'let' or 'const' instead
[...]/node_modules/ng2-logger/src/log.ts[88, 49]: Missing semicolon
[...]/node_modules/ng2-logger/src/log.ts[81, 31]: == should be ===
[...]/node_modules/ng2-logger/src/log.ts[80, 45]: missing whitespace
[...]/node_modules/ng2-logger/src/log.ts[80, 53]: missing whitespace
[...]/node_modules/ng2-logger/src/log.ts[81, 11]: missing whitespace
[...]/node_modules/ng2-logger/src/log.ts[82, 11]: missing whitespace
[...]/node_modules/ng2-logger/src/log.ts[87, 15]: missing whitespace

npm audit vulnerabilities

Hi!

Recently I've updated our package to use the latest version of ng2-logger and running the npm audit on the resulting package-lock has revealed several vulnerabilities (I think primarily due to the underlying dependencies in tnp-core.) Is it possible to release a new version with the updated dependencies to resolve these vulnerabilities?

json5 2.0.0 - 2.2.1
Severity: high
Prototype Pollution in JSON5 via Parse Method - GHSA-9c47-m6qq-7p4h
fix available via npm audit fix --force
Will install [email protected], which is a breaking change
node_modules/ng2-logger/node_modules/json5
node_modules/tnp-core/node_modules/json5
ng2-logger 4.0.8 - 7.0.13 || >=8.0.4
Depends on vulnerable versions of json5
Depends on vulnerable versions of tnp-config
node_modules/ng2-logger
tnp-core <=0.0.60 || >=1.0.3
Depends on vulnerable versions of json5
Depends on vulnerable versions of lodash
Depends on vulnerable versions of moment
node_modules/tnp-core
tnp-config 0.0.35 - 0.0.89 || >=1.0.2
Depends on vulnerable versions of tnp-core
node_modules/tnp-config

lodash <=4.17.20
Severity: critical
Regular Expression Denial of Service (ReDoS) in lodash - GHSA-x5rq-j2xg-h7qm
Prototype Pollution in lodash - GHSA-fvqr-27wr-82fm
Prototype Pollution in lodash - GHSA-jf85-cpcp-j695
Prototype Pollution in lodash - GHSA-p6mc-m468-83gw
Command Injection in lodash - GHSA-35jh-r3h4-6jhm
fix available via npm audit fix --force
Will install [email protected], which is a breaking change
node_modules/tnp-core/node_modules/lodash
tnp-core <=0.0.60 || >=1.0.3
Depends on vulnerable versions of json5
Depends on vulnerable versions of lodash
Depends on vulnerable versions of moment
node_modules/tnp-core
tnp-config 0.0.35 - 0.0.89 || >=1.0.2
Depends on vulnerable versions of tnp-core
node_modules/tnp-config
ng2-logger 4.0.8 - 7.0.13 || >=8.0.4
Depends on vulnerable versions of json5
Depends on vulnerable versions of tnp-config
node_modules/ng2-logger

minimist <=0.2.3
Severity: critical
Prototype Pollution in minimist - GHSA-vh95-rmgr-6w4m
Prototype Pollution in minimist - GHSA-xvch-5gv4-984h
fix available via npm audit fix
node_modules/tnp-core/node_modules/mkdirp/node_modules/minimist
mkdirp 0.4.1 - 0.5.1
Depends on vulnerable versions of minimist
node_modules/tnp-core/node_modules/mkdirp

moment <=2.29.3
Severity: high
Path Traversal: 'dir/../../filename' in moment.locale - GHSA-8hfj-j24r-96c4
Moment.js vulnerable to Inefficient Regular Expression Complexity - GHSA-wc69-rhjr-hc9g
fix available via npm audit fix --force
Will install [email protected], which is a breaking change
node_modules/tnp-core/node_modules/moment
tnp-core <=0.0.60 || >=1.0.3
Depends on vulnerable versions of json5
Depends on vulnerable versions of lodash
Depends on vulnerable versions of moment
node_modules/tnp-core
tnp-config 0.0.35 - 0.0.89 || >=1.0.2
Depends on vulnerable versions of tnp-core
node_modules/tnp-config
ng2-logger 4.0.8 - 7.0.13 || >=8.0.4
Depends on vulnerable versions of json5
Depends on vulnerable versions of tnp-config
node_modules/ng2-logger

sync-exec *
Severity: moderate
Tmp files readable by other users in sync-exec - GHSA-38h8-x697-gh8q
fix available via npm audit fix
node_modules/sync-exec
copy-paste >=1.1.4
Depends on vulnerable versions of sync-exec
node_modules/copy-paste

setProductionMode

The doc shows this example how to enable selective debugging

Log.setProductionMode();
Log.onlyModules('src:books', 'src:records', 'src:page:login');
Log.onlyLevel(Level.ERROR,Level.INFO);

However it looks as if "setProductionMode" disables the logging altogether, even if levels or modules are enabled afterwards. Is this as intended?

Strange output when built for production

Hi there,

nice project.

I have an issue though. When I build the project for production then, for example, a simillar part of code:

this.logger.d('Retrieved all points after ' +
      (performance.now() - t0) + ' milliseconds or ' +
      (performance.now() - t0) / 1000 + ' seconds'
    );

Gets printed as:

screen shot 2017-09-16 at 19 24 35

Instead of:

screen shot 2017-09-16 at 19 25 27

ng2-logger not working in lazy loading sub-module IE 11 (Angular8)

We are using "ng2-logger": "~3.0.11" and while it seems to be working fine for all browsers and submodules (Angular lazy loading) it wont work in IE11 and in particular for lazy loaded modules (it works for top level modules). Attached is the exception. Do you happen to have any idea what might be wrong ?
image

Proposal For Log.onlyModules(modules:string[]) Behaviour

Hi there,

Suggestion 1:
Looking at the code and testing with the logger, it appears that once the function Log.onlyModules() is called with a set of named modules, if the Log.create() function is subsequently called, it will return "undefined". Thus it isn't possible for you to turn off logging of specific modules without breaking code (i.e. EXCEPTION: Cannot read property 'd' of undefined)

May I suggest this:

  • When the "create" function is called, a logger is always created. However if is not mentioned as one of the modules to output logs for via Log.onlyModules(), mute its output.
  • If Log.onlyModules() is called after a log is instantiated because of order of execution, have Logger instance muted at that point.

Suggestion 2:
It is great to see that multiple modules can be specified to the Log.onlyModules() function. However the modules must be explicitly listed and this can get unwieldy. Generally libraries like debug allow you to specify module patterns with globs. I propose that regular expressions are used, although globs can be added also.

Pull request to follow.

Property 'includes' does not exist on type 'string[]'

Attempting to use this within an Ionic 2 app (Typescript, Angular 2).

Error dump:

➜  i2-app ionic serve

Running 'serve:before' gulp task before serve
[15:57:06] Starting 'clean'...
[15:57:06] Finished 'clean' after 37 ms
[15:57:06] Starting 'watch'...
[15:57:06] Starting 'sass'...
[15:57:06] Starting 'html'...
[15:57:06] Starting 'fonts'...
[15:57:06] Starting 'scripts'...
[15:57:06] Finished 'scripts' after 40 ms
[15:57:06] Finished 'html' after 43 ms
[15:57:06] Finished 'fonts' after 46 ms
[15:57:07] Finished 'sass' after 799 ms
TypeScript error: /appdir/node_modules/ng2-logger/src/log.ts(12,52): Error TS2339: Property 'includes' does not exist on type 'string[]'.
TypeScript error: /appdir/node_modules/ng2-logger/src/log.ts(41,25): Error TS2339: Property 'includes' does not exist on type 'Level[]'.
TypeScript error: /appdir/node_modules/ng2-logger/src/log.ts(43,42): Error TS2339: Property 'name' does not exist on type 'typeof Log'.
TypeScript error: /appdir/node_modules/ng2-logger/src/log.ts(46,42): Error TS2339: Property 'name' does not exist on type 'typeof Log'.
TypeScript error: /appdir/node_modules/ng2-logger/src/log.ts(49,42): Error TS2339: Property 'name' does not exist on type 'typeof Log'.
TypeScript error: /appdir/node_modules/ng2-logger/src/log.ts(52,42): Error TS2339: Property 'name' does not exist on type 'typeof Log'.
TypeScript error: /appdir/node_modules/ng2-logger/src/logger.ts(15,54): Error TS2339: Property 'includes' does not exist on type 'Level[]'.
TypeScript error: /appdir/node_modules/ng2-logger/src/logger.ts(16,30): Error TS2339: Property 'includes' does not exist on type 'Level[]'.
TypeScript error: /appdir/node_modules/ng2-logger/src/logger.ts(19,60): Error TS2339: Property 'includes' does not exist on type 'Level[]'.
TypeScript error: /appdir/node_modules/ng2-logger/src/logger.ts(26,54): Error TS2339: Property 'includes' does not exist on type 'Level[]'.
TypeScript error: /appdir/node_modules/ng2-logger/src/logger.ts(27,30): Error TS2339: Property 'includes' does not exist on type 'Level[]'.
TypeScript error: /appdir/node_modules/ng2-logger/src/logger.ts(30,60): Error TS2339: Property 'includes' does not exist on type 'Level[]'.
TypeScript error: /appdir/node_modules/ng2-logger/src/logger.ts(37,54): Error TS2339: Property 'includes' does not exist on type 'Level[]'.
TypeScript error: /appdir/node_modules/ng2-logger/src/logger.ts(38,30): Error TS2339: Property 'includes' does not exist on type 'Level[]'.
TypeScript error: /appdir/node_modules/ng2-logger/src/logger.ts(41,60): Error TS2339: Property 'includes' does not exist on type 'Level[]'.
TypeScript error: /appdir/node_modules/ng2-logger/src/logger.ts(48,54): Error TS2339: Property 'includes' does not exist on type 'Level[]'.
TypeScript error: /appdir/node_modules/ng2-logger/src/logger.ts(49,30): Error TS2339: Property 'includes' does not exist on type 'Level[]'.
TypeScript error: /appdir/node_modules/ng2-logger/src/logger.ts(52,60): Error TS2339: Property 'includes' does not exist on type 'Level[]'.
[15:57:09] Finished 'watch' after 3.07 s
[15:57:09] Starting 'serve:before'...
[15:57:09] Finished 'serve:before' after 3.77 μs

Running live reload server: http://localhost:35729
Watching: www/**/*, !www/lib/**/*
√ Running dev server:  http://localhost:8100
Ionic server commands, enter:
  restart or r to restart the client app from the root
  goto or g and a url to have the app navigate to the given url
  consolelogs or c to enable/disable console log output
  serverlogs or s to enable/disable server log output
  quit or q to shutdown the server and exit

ionic $
/appdir/node_modules/ng2-logger/ng2-logger.ts:1
export * from './src';
^
ParseError: 'import' and 'export' may appear only with 'sourceType: module'

app.ts:

import { Component } from '@angular/core';
import { Platform, ionicBootstrap } from 'ionic-angular';
import { StatusBar } from 'ionic-native';
import { TabsPage } from './pages/tabs/tabs';

import { Log, Level } from 'ng2-logger/ng2-logger'

const log = Log.create('app');

@Component({
  template: '<ion-nav [root]="rootPage"></ion-nav>'
})
export class MyApp {

  public rootPage: any;

  constructor(private platform: Platform) {
    this.rootPage = TabsPage;
    let obj = {test: 1};

    log.d('object',obj) // console.log
    log.er('object',obj) // console.error
    log.i('object',obj) // console.info
    log.w('object',obj) // console.warn
    console.log('here')

    platform.ready().then(() => {
      // Okay, so the platform is ready and our plugins are available.
      // Here you can do any higher level native things you might need.
      StatusBar.styleDefault();
    });
  }
}

ionicBootstrap(MyApp);

Any ideas?

Feature: add an observable

Hi,

Do you think it could be possible to add an observable which could be subscribed in order to retrieve and use all logging events in another component?
Of course no need to store an history of the events, just emit on the observable each time a new log request occurs.
This would require to have a global service available across all the instances of the logger, I don't know if it's possible for you to do such a thing.

Thanks a lot.

Ng serve failed on ng2-logger version 2.0.38 with Angular 7

Ng serve failed with following message

ERROR in ./node_modules/ng2-logger/backend-logging.js
Module not found: Error: Can't resolve 'fs' in '/tmp/prod-stockholm/node_modules/ng2-logger'
ERROR in ./node_modules/ng2-logger/display.js
Module not found: Error: Can't resolve 'path' in '/tmp/prod-stockholm/node_modules/ng2-logger'
ERROR in ./node_modules/ng2-logger/backend-logging.js
Module not found: Error: Can't resolve 'path' in '/tmp/prod-stockholm/node_modules/ng2-logger'
ℹ 「wdm」: Failed to compile.

I am importing ng2-logger/client and also tried ng2-logger/browser

Error when using with Jasmine & Karma

Hi,
There is an error while using it with Karma:

ERROR in C:/Dev/GitLab/arya/node_modules/ng2-logger/src/log.ts (99,46): Property 'clear' does not exist on type 'Console'.
C:/Dev/GitLab/arya/node_modules/ng2-logger/src/log.ts (100,13): Supplied parameters do not match any signature of call target.
C:/Dev/GitLab/arya/node_modules/ng2-logger/src/log.ts (101,25): Property 'clear' does not exist on type 'Console'.

currently my workaround is to remove setProductionMode method.
Appreciate if you can check the issue / share your thoughts.

Nir.

Wrong colors for info and error

I have noted that the border's color when I log info and error are inverted:

  • info has a red border,
  • error has a light blue border.

I have checked the source and there is something strange. The logger.ts file has everything ok whereas the logger.js one has the logger level inverted for the functions "i" and "e".
Can you check as well and correct please ?

console.info console.warn console.error on other browsers

Most browsers support console.warn/error/info, not just IE :)
Would be nice to have the proper log channel, as (i.e. in chrome) each channel can be enabled/disabled in dev tools and each channel has a matching icon in front of the log message

Can't build with angular 12 and npm 7

Basically my build fails for angular 12 / npm 7 because the package.json declares the following:
"main": "esm2015/index.js"
But no such file exists in the folder after npm install

Any idea how to fix this?

Thanks!

Error: Failed to compile entry-point ng2-logger ('main' as unknown format) due to property 'main' pointing to a missing or empty file: esm2015/index.js at C:\WS\Angular\MyApp\node_modules\@angular\compiler-cli\ngcc\src\execution\tasks\completion.js:57:19 at C:\WS\Angular\MyApp\node_modules\@angular\compiler-cli\ngcc\src\execution\tasks\completion.js:31:13 at C:\WS\Angular\MyApp\node_modules\@angular\compiler-cli\ngcc\src\execution\create_compile_function.js:47:21 at SingleProcessExecutorSync.SingleProcessorExecutorBase.doExecute (C:\WS\Angular\MyApp\node_modules\@angular\compiler-cli\ngcc\src\execution\single_process_executor.js:36:17) at C:\WS\Angular\MyApp\node_modules\@angular\compiler-cli\ngcc\src\execution\single_process_executor.js:57:59 at SyncLocker.lock (C:\WS\Angular\MyApp\node_modules\@angular\compiler-cli\ngcc\src\locking\sync_locker.js:34:24) at SingleProcessExecutorSync.execute (C:\WS\Angular\MyApp\node_modules\@angular\compiler-cli\ngcc\src\execution\single_process_executor.js:57:27) at Object.mainNgcc (C:\WS\Angular\MyApp\node_modules\@angular\compiler-cli\ngcc\src\main.js:74:25) at Object.process (C:\WS\Angular\MyApp\node_modules\@angular\compiler-cli\ngcc\index.js:29:23) at NgccProcessor.processModule (C:\WS\Angular\MyApp\node_modules\@ngtools\webpack\src\ngcc_processor.js:175:16) at C:\WS\Angular\MyApp\node_modules\@ngtools\webpack\src\ivy\host.js:146:18 at C:\WS\Angular\MyApp\node_modules\@ngtools\webpack\src\ivy\host.js:76:24 at Array.map (<anonymous>) at Object.host.resolveModuleNames (C:\WS\Angular\MyApp\node_modules\@ngtools\webpack\src\ivy\host.js:74:32) at C:\WS\Angular\MyApp\node_modules\@ngtools\webpack\src\ivy\host.js:75:55 at Array.map (<anonymous>) An unhandled exception occurred: Failed to compile entry-point ng2-logger ('main' as unknown format) due to property 'main' pointing to a missing or empty file: esm2015/index.js

EDIT: As an added note, when I manually copy the file node_modules/ng2-logger/index.js into ./client/esm2015/ and ./browser/esm2015 folders, the ngcc compilation is successful.
The same needs to be done with helper.js for the angular build to succeed.

I would make a Pull request but I don't understand the build system used in this project.

log source

logs

Hi, I'm just interesting, how I can get the same functionality as in "console.log", where I can get link to a
code line where the log is calling? (ex: componentname.component.ts:175). By ng2-logger I get link only to "display.ts". Sorry for a dumb question, but I can't get it.

npm install moderate vulnerability

Hi there. On a new Angular 13.03 project, I'm getting one moderate vulnerability at npm install, which seems to be caused by an indirect dependency of ng2-logger (i.e. sync-exec). I'm not sure how easy it would be to address it, but I just wanted to make you guys aware of it.

Btw, I'm using this version of the library: "ng2-logger": "^8.0.20".

Npm audit output:

  Moderate        Tmp files readable by other users in sync-exec                

  Package         sync-exec                                                     

  Patched in      No patch available                                            

  Dependency of   ng2-logger                                                    

  Path            ng2-logger > tnp-cli > tnp-config > tnp-core > copy-paste >   
                  sync-exec                                                     

  More info       https://github.com/advisories/GHSA-38h8-x697-gh8q      

found 1 moderate severity vulnerability in 1422 scanned packages
  1 vulnerability requires manual review. See the full report for details.

Manual import of Log class

Hi,

I don't know if this is an issue at all. Sorry if not.

Every time I use the Log class, i.e. Log.create('Component'); I need to manually import it: import { Log } from 'ng2-logger/ng2-logger';. I don't understand the reason why my IDE (PhpStorm) cannot autoimport this class as it does with all the other classes, components, models, services, etc.

Thanks!

Error when compiling Angular2 app after including ng2-logger

After including ng2-logger, i now get the following error output when compiling:

ERROR in [default] [...]\node_modules\ng2-logger\src\include.ts:1:9
'Level' is declared but never used.

ERROR in [default] [...]\node_modules\ng2-logger\src\logger.ts:6:20
'T' is declared but never used.

ERROR in [default] [...]\node_modules\ng2-logger\src\logger.ts:12:16
Property 'developmentMode' is declared but never used.

ERROR in [default] [...]\node_modules\ng2-logger\src\logger.ts:61:12
'_logMessage' is declared but never used.

ERROR in [default] [...]\node_modules\ng2-logger\src\logger.ts:75:12
'level' is declared but never used.

TypeScript 2.0.10
Angular 2.4.4
ng2-logger 0.1.21

ng2-logger and jasmine/karma

I get this weird error in my unit tests:

WARNING in ./node_modules/ng2-logger/src/logger.js
(Emitted value instead of an instance of Error) Cannot find source file 'logger.ts': Error: Can't resolve './logger.ts' in '/XXXXX/node_modules/ng2-logger/src'
@ ./node_modules/ng2-logger/src/log.js 3:15-34
@ ./node_modules/ng2-logger/src/index.js
@ ./node_modules/ng2-logger/index.js
@ ./src/app/shared/services/AService.service.ts
@ ./src/test/AService.spec.ts
@ ./src .spec.ts
@ ./config/karma-shim.js

While it works perfectly in the app, I get this error when testing...
Any idea?

Angular 16 runtime error Cannot set properties of undefined (setting 'black') at 91202 (tnp-core.mjs:471:34)

Hi!

I just migrated from angular 14 to angular 15 and then 16 while upgrading my packages but I get a runtime error when I include ng2-logger.

Uncaught TypeError: Cannot set properties of undefined (setting 'black') at 91202 (tnp-core.mjs:471:34)

I dug a little deeping and it seems to be caused by the "tnp-core lib/node-chalk-mock.ts" dependency declared for the ng2-logger project.

I target es2022 in tsconfig.

This is caused by something for target es2022 that generates this wrong code in tnp-core/lib/node-chalk-mock :

const allObj = {
    black(a) {
        console.log(a);
    },
    gray(a) {
        console.log(a);
    },
    red(a) {
        console.log(a);
    },
    green(a) {
        console.log(a);
    },
    italic(a) {
        console.log(a);
    },
    magenta(a) {
        console.log(a);
    },
    bold(a) {
        console.log(a);
    },
    underline(a) {
        console.log(a);
    },
};
const map = new Map();
const all = Object.keys(allObj).map(key => {
    map.set(allObj[key], key);
    return allObj[key];
});
for (let i = 0; i < all.length; i++) {
    const e1 = all[i];
    for (let j = 0; j < all.length; j++) {
        const e2 = all[j];
        e1.prototype[map.get(e2)] = e2;
    }
}

If I override ng2-logger to use tnp-config/[email protected], then it works.

"overrides": {
    "ng2-logger": {
      "tnp-config": "16.0.14",
      "tnp-core": "16.0.14"
    }
  },

Let me know if I can provide any more information!

Injecting as service

Rather than newing it up, is there a recommended way to pull this in as an injectable service?

Thanks

Reconfiguration after initialization?

I noticed that the logger cannot be reconfigured after initialization, i.e. setProductionMode.

Is this intended and why? Thanks for your feedback!

Log.display passing wrong arguments

Display.msg signature is static msg( message: string | any, params: any[], moduleName: string, moduleColor: string, level: Level, moduleWidth: number | undefined )

and in log.ts, the third parameter being passed into Display.msg is name instead of moduleName .

 private static display(name: string, data: any, incomming: Level, moduleName: string) {
        if (!contain(Log.levels, incomming)) return;
        if (incomming === Level.DATA) {
            Display.msg(name, data, name, Log.instances[moduleName].color,
                Level.DATA, Log.instances[moduleName].fixedWidth);
        }
        if (incomming === Level.ERROR) {
            Display.msg(name, data, name, Log.instances[moduleName].color,
                Level.ERROR, Log.instances[moduleName].fixedWidth);
        }
        if (incomming === Level.INFO) {
            Display.msg(name, data, name, Log.instances[moduleName].color,
                Level.INFO, Log.instances[moduleName].fixedWidth);
        }
        if (incomming === Level.WARN) {
            Display.msg(name, data, name, Log.instances[moduleName].color,
                Level.WARN, Log.instances[moduleName].fixedWidth);
        }
    }

Typo in "onlyLevel"

I think that instead of

if (Log._logOnly) Log._logOnly = true;

if should read

if (!Log._logOnly) Log._logOnly = true;

License

I would like to use this but I can't if there is no license.
I need to know if royalties or credits are a must.

Feature: Add Timers

Following the Console Web Api the timers functions are missing.

console.time("answer time");
alert("Click to continue");
console.timeEnd("answer time");

Angular 2 error/warning '.../node_modules/ng2-logger/ng2-logger.ts' is not under 'rootDir'

I guess .ts files should not be downloaded with npm install. Otherwise it causes warning:

[default] File '.../node_modules/ng2-logger/ng2-logger.ts' is not under 'rootDir' '.../src'. 'rootDir' is expected to contain all source files.
[default] File '.../node_modules/ng2-logger/src/display.ts' is not under 'rootDir' '.../src'. 'rootDir' is expected to contain all source files.
[default] File '.../node_modules/ng2-logger/src/include.ts' is not under 'rootDir' '.../src'. 'rootDir' is expected to contain all source files.
[default] File '.../node_modules/ng2-logger/src/index.ts' is not under 'rootDir' '.../src'. 'rootDir' is expected to contain all source files.
[default] File '.../node_modules/ng2-logger/src/level.ts' is not under 'rootDir' '.../src'. 'rootDir' is expected to contain all source files.
[default] File '.../node_modules/ng2-logger/src/log.ts' is not under 'rootDir' '.../src'. 'rootDir' is expected to contain all source files.
[default] File '.../node_modules/ng2-logger/src/logger.ts' is not under 'rootDir' '.../src'. 'rootDir' is expected to contain all source files.

No build source

Hi,

nice feature but I'm not able to include it into my project as angular module because after npm install (no js sources) have to include it into my source folder to compile and use

or im doing something wrong :)

Regards
Andrej

Log.onlyModules() doesn't work

Hi,

When I create a new Logger using Log.create, it is provided with isMuted = true (I've configured Log.onlyModules accordingly), but this field is not used by any logging methods. Am I misconfigured something?

Why other methods like d(), i(), ... etc doesn't use isMuted to track whether message should be printed or not?

Feature: Clear

Following the Console Web Api the Clear function is missing

console.clear();

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.