Activities

phamhoaithuong

phamhoaithuong posted a new question

consola •

Err Creating a new instance

import consola from 'consola'

const logger = consola.create({
// level: 4,
reporters: new consola.JSONReporter() ,
defaults: {
additionalColor: 'white'
}
})

Error TS2339 (TS) Property 'JSONReporter' does not exist on type 'Consola'.
Error TS2322 (TS) Type '{ additionalColor: string; }' is not assignable to type 'ConsolaLogObject'.
Object literal may only specify known properties, and 'additionalColor' does not exist in type 'ConsolaLogObject'.
i'm using code in document, but it have error. i don't nkow how to fix it. pls help me, thanks you very much.

mathieutu

mathieutu posted a new bug report

consola •

bug Doesn't handle native console string substitutions.

Version

v2.10.0

Reproduction link

https://codesandbox.io/embed/fervent-pine-su2ty

Steps to reproduce

Hi folks,

Consola is not handling the native string substitutions of console.
https://developer.mozilla.org/en-US/docs/Web/API/console#Using_string_substitutions

This leads to issues when when using wrapConsole method in code bases where you don't control logs.

Example: there is a problem with all the react errors.

Here an example before/after the wrap:

- Warning: Received `true` for a non-boolean attribute `secondary`.
+ Warning: Received `%s` for a non-boolean attribute `%s`.

- If you want to write it to the DOM, pass a string instead: secondary="true" or secondary={value.toString()}.
+ If you want to write it to the DOM, pass a string instead: %s="%s" or %s={value.toString()}.%s true secondary secondary true secondary 
    in h1 (created by App)
    in div (created by App)
    in App

For me, consola should have the same api than console, to be able to replace it properly.

How can we handle that?

Thanks for your work,
Matt'.

What is expected ?

Consola should have at least the same api and features than console.

What is actually happening?

Features from console are missing in consola (browser and node).

MANJUSAK

MANJUSAK posted a new question

consola •

The project is almost an example of js. Can you provide an example of ts? thank you very much

The project is almost an example of js. Can you provide an example of ts? thank you very much

MANJUSAK

MANJUSAK posted a new question

consola •

Best to give a TS example

The project is almost an example of js. Can you provide an example of ts? thank you very much

parth444

parth444 posted a new bug report

consola •

bug SyntaxError: Unexpected token ... on node 6.10.3

Version

v2.9.0

Reproduction link

[No link needed](No link needed)

Steps to reproduce

Create a file test.js and add following line:

var consola = require('consola');

What is expected ?

No errors when running on node 6.10.3

What is actually happening?

(function (exports, require, module, __filename, __dirname) { "use strict";function _interopDefault(u){return u&&"object"==typeof u&&"default"in u?u.default:u}var util=_int
eropDefault(require("util")),path=require("path"),fs=require("fs"),os=_interopDefault(require("os")),commonjsGlobal="undefined"!=typeof globalThis?globalThis:"undefined"!=t
ypeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function createCommonjsModule(u,e){return u(e={exports:{}},e.exports),e.exports}funct
ion getCjsExportFromNamespace(u){return u&&u.default||u}var vendors=[{name:"AppVeyor",constant:"APPVEYOR",env:"APPVEYOR",pr:"APPVEYOR_PULL_REQUEST_NUMBER"},{name:"Bamboo",c
onstant:"BAMBOO",env:"bamboo_planKey"},{name:"Bitbucket Pipelines",constant:"BITBUCKET",env:"BITBUCKET_COMMIT"},{name:"Bitrise",constant:"BITRISE",env:"BITRISE_IO",pr:"BITR
ISE_PULL_REQUEST"},{name:"Buddy",constant:"BUDDY",env:"BUDDY_WORKSPACE_ID",pr:"BUDD
SyntaxError: Unexpected token ...
    at createScript (vm.js:56:10)
    at Object.runInThisContext (vm.js:97:10)
    at Module._compile (module.js:542:28)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (C:\Users\Default\Desktop\test.js:1:77)
parth444

parth444 posted a new question

consola •

SyntaxError: Unexpected token ... on node 6.10.3

Version
2.9.0

Steps to reproduce
Create a file test.js and add following line:

var consola = require('consola');

What is expected ?
No errors when running on node 6.10.3

What is actually happening?

(function (exports, require, module, __filename, __dirname) { "use strict";function _interopDefault(u){return u&&"object"==typeof u&&"default"in u?u.default:u}var util=_int
eropDefault(require("util")),path=require("path"),fs=require("fs"),os=_interopDefault(require("os")),commonjsGlobal="undefined"!=typeof globalThis?globalThis:"undefined"!=t
ypeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function createCommonjsModule(u,e){return u(e={exports:{}},e.exports),e.exports}funct
ion getCjsExportFromNamespace(u){return u&&u.default||u}var vendors=[{name:"AppVeyor",constant:"APPVEYOR",env:"APPVEYOR",pr:"APPVEYOR_PULL_REQUEST_NUMBER"},{name:"Bamboo",c
onstant:"BAMBOO",env:"bamboo_planKey"},{name:"Bitbucket Pipelines",constant:"BITBUCKET",env:"BITBUCKET_COMMIT"},{name:"Bitrise",constant:"BITRISE",env:"BITRISE_IO",pr:"BITR
ISE_PULL_REQUEST"},{name:"Buddy",constant:"BUDDY",env:"BUDDY_WORKSPACE_ID",pr:"BUDD
SyntaxError: Unexpected token ...
    at createScript (vm.js:56:10)
    at Object.runInThisContext (vm.js:97:10)
    at Module._compile (module.js:542:28)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (C:\Users\Default\Desktop\test.js:1:77)
parth444

parth444 posted a new question

consola •

SyntaxError: Unexpected token ... for node 6.10.3

Version
2.9.0

Steps to reproduce
Create test.js and add:

var consola = require('consola');

What is expected ?
No errors when running node 6.10.3

What is actually happening?

(function (exports, require, module, __filename, __dirname) { "use strict";function _interopDefault(u){return u&&"object"==typeof u&&"default"in u?u.default:u}var util=_int
eropDefault(require("util")),path=require("path"),fs=require("fs"),os=_interopDefault(require("os")),commonjsGlobal="undefined"!=typeof globalThis?globalThis:"undefined"!=t
ypeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function createCommonjsModule(u,e){return u(e={exports:{}},e.exports),e.exports}funct
ion getCjsExportFromNamespace(u){return u&&u.default||u}var vendors=[{name:"AppVeyor",constant:"APPVEYOR",env:"APPVEYOR",pr:"APPVEYOR_PULL_REQUEST_NUMBER"},{name:"Bamboo",c
onstant:"BAMBOO",env:"bamboo_planKey"},{name:"Bitbucket Pipelines",constant:"BITBUCKET",env:"BITBUCKET_COMMIT"},{name:"Bitrise",constant:"BITRISE",env:"BITRISE_IO",pr:"BITR
ISE_PULL_REQUEST"},{name:"Buddy",constant:"BUDDY",env:"BUDDY_WORKSPACE_ID",pr:"BUDD
SyntaxError: Unexpected token ...
    at createScript (vm.js:56:10)
    at Object.runInThisContext (vm.js:97:10)
    at Module._compile (module.js:542:28)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (C:\Users\Default\Desktop\test.js:1:77)
duyleekun

duyleekun posted a new bug report

consola •

bug Incorrect cmty link in issue template

Version

2.8.1

Reproduction link

https://github.com/nuxt/consola/issues/new

Steps to reproduce

What is expected ?

https://cmty.app/nuxt/issues/new?type=bug-report&repo=consola

What is actually happening?

https://nuxtjs.cmty.io/issues/new

duyleekun

duyleekun posted a new bug report

consola •

bug Uncaught TypeError: Illegal invocation while log.apply(void 0, ...

Version

2.8.1

Reproduction link

[http://not-available.com/Always broken on webview android 6.0.0](http://not-available.com/Always broken on webview android 6.0.0)

Steps to reproduce

Using android emulator with version 6.0.0

Having any consola.log will result in Uncaught TypeError: Illegal invocation due to https://stackoverflow.com/questions/8159233/typeerror-illegal-invocation-on-console-log-apply/8159338#8159338

The related snippet in consola/dist/consola.browser.js is

                return r(t, [{
                    key: "log",
                    value: function(e) {
                        var t = e.level < 1 ? console.__error || console.error : 1 === e.level && console.warn ? console.__warn || console.warn : console.__log || console.log
                          , r = "log" !== e.type ? e.type : ""
                          , s = e.tag ? e.tag : ""
                          , n = this.typeColorMap[e.type] || this.levelColorMap[e.level] || this.defaultColor
                          , i = "\n      background: ".concat(n, ";\n      border-radius: 0.5em;\n      color: white;\n      font-weight: bold;\n      padding: 2px 0.5em;\n    ");
                        t.apply(void 0, ["%c" + [s, r].filter(Boolean).join(":"), i].concat(o(e.args)))
                    }
                }]),

What is expected ?

Not throwing any exception in old browser

What is actually happening?

Throwing Uncaught TypeError: Illegal invocation

Additional comments?

Replace void 0 with console will resolve this for my case

KaelWD

KaelWD posted a new question

consola •

Illegal invocation

Note: nuxtjs.cmty.io does not exist


Your compiler is turning consoleLogFn(...args) into consoleLogFn.apply(void 0, args), which is invalid in older browsers: https://stackoverflow.com/a/8159338/2074736

maoberlehner

maoberlehner posted a new bug report

consola •

bug Maximum call stack size exceeded when using in combination with global-prefix

Version

v2.5.8

Reproduction link

https://codesandbox.io/s/14ljokmml4

Steps to reproduce

CodeSandbox: https://codesandbox.io/s/14ljokmml4 (unfortunately I can't get the CodeSandbox to run again after changing the nuxt.config.js and restarting. Please download the CodeSandbox and run locally to reproduce. Thx!)

  1. Install Nuxt
  2. Install and configure node-sass-magic-importer (see nuxt.config.js in CodeSandbox)
  3. Run npm run generate

What is expected ?

nuxt generate should do its job

What is actually happening?

100% CPU and nothing else seems to happen (because the developers of global-prefix use try / catch without logging the error).

Additional comments?

I've hunted down the error to the global-prefix package to the following lines: https://github.com/jonschlinkert/global-prefix/blob/master/index.js#L65

Add a console.error(err) in the catch section to see the Maximum call stack size exceeded error in node_modules/consola/dist/consola.js. Remove the try / catch block and just return null everything works fine.

Everything worked fine before Nuxt 2.5 so I assume something has changed with this package with the 2.5 release?

Thanks for the great work on Nuxt.js - I'm a big fan!

maoberlehner

maoberlehner posted a new question

consola •

Maximum call stack size exceeded when using in combination with global-prefix

I hope this does not get deleted automatically, but https://nuxtjs.cmty.io/issues/new does not work!

Reproduction:

CodeSandbox: https://codesandbox.io/s/y0yxr7923j (unfortunately I can't get the CodeSandbox to run again after changing the nuxt.config.js and restarting. Please download the CodeSandbox and run locally to reproduce. Thx!)

  1. Install Nuxt
  2. Install and configure node-sass-magic-importer (see nuxt.config.js in CodeSandbox)
  3. Run npm run generate
  4. 100% CPU and nothing else happens (because the developers of global-prefix use try / catch without logging the error).

I've hunted down the error to the global-prefix package to the following lines: https://github.com/jonschlinkert/global-prefix/blob/master/index.js#L65

Add a console.error(err) in the catch section to see the Maximum call stack size exceeded error in node_modules/consola/dist/consola.js. Remove the try / catch block and just return null everything works fine.

Everything worked fine before Nuxt 2.5 so I assume something has changed with this package with the 2.5 release?

Thanks for the great work on Nuxt.js - I'm a big fan!

pimlie

pimlie posted a new feature request

consola •

idea Export dist for src/index.js

What problem does this feature solve?

Previous versions of consola exported all the internals which I used to create my own Consola instance in nuxt-generate-cluster: https://github.com/nuxt-community/nuxt-generate-cluster/blob/master/lib/utils/consola.js

Currently it seems the only export that is distributed is the consola instance. Which also means that the README is probably not correct. Eg when I log consola.JSONReporter it logs undefined (referring to this: https://github.com/nuxt/consola#creating-a-new-instance)

What does the proposed changes look like?

I'd also be happy with a third build file, eg so I have to import eg consola/dist/Consola to get access to all the exports in https://github.com/nuxt/consola/blob/master/src/index.js

Not sure what the best name for such an export would be

matchai

matchai posted a new bug report

consola •

bug TypeScript typings only allow for logging of strings

Version

v2.1.0

Reproduction link

https://codesandbox.io/s/r4kk7o5jl4?module=%2Fsrc%2Findex.ts&view=editor

Steps to reproduce

  1. Create a TypeScript project.
  2. Try logging an Error, number, or object.

What is expected ?

Consola types support logging with "any".

What is actually happening?

Consola only supports the string type.

JulianMined

JulianMined posted a new question

consola •

Typescript Issue

Hello,
i´m trying to use the library in with Typescript but "consola" is undefined.

script.ts
import consola from "consola";
console.log(typeof consola);

tsconfig.json
{
"compilerOptions": {
"module": "commonjs",
"lib": ["es2015"],
"target": "es2015",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"sourceMap": true,
"allowJs": true
}
}

manniL

manniL posted a new bug report

consola •

bug Missing types

Version

v2.1.0

Description

There are missing types for the following functions:

  • create
  • setReporters
  • withTag
  • withScope
  • wrapAll
  • restoreAll
  • wrapConsole
  • restoreConsole
  • wrapStd
  • restoreStd
  • pauseLogs
  • resumeLogs
  • mockTypes
nevf

nevf posted a new question

consola •

How to use FancyReporter etc.

I have consola working with the default BasicReporter which is included in the JS file, however I can't work out how to use other reporters such as FancyReporter. None of the other reporters are installed using npm i consola.

Also should tags be displayed with BasicReporter? If so I can't get them to work.

Finally it would be great to see better documentation and an article on usage with examples would also be most welcome..

rkgrep

rkgrep posted a new feature request

consola •

idea TypeScript definitions

What problem does this feature solve?

I want to use consola in an express app written in TS, but for some reason definitions are excluded from final build published to NPM

Tom-Bonnike

Tom-Bonnike posted a new bug report

consola •

bug Maximum call stack size exceeded in browser?

Version

2.2.3

Reproduction link

https://codesandbox.io/s/vj522nv827

Steps to reproduce

  • Use wrapAll
  • Use any console.* method after that

What is expected ?

The log is enhanced

What is actually happening?

  • The page crashes because of maximum call stack size exceeded.
  • The browser reporter keeps on calling itself.
pi0

pi0 posted a new question

consola •

consola v3 proposal
  • Use Proxy instead of creating closures for each log type. This allows using arbitrary log types and less overhead of tagged loggers and easier mocking
  • Find a way to make tagged loggers more lightweight when using withTag
  • Deprecate withDefaults and create (Keep for legacy but create a new class instance`
  • Support logs with timer (Using a token?)
  • Seperate <type>(logOjb) from <type>(args. (How?)