-
Notifications
You must be signed in to change notification settings - Fork 184
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: improve packaging for browser support
- Loading branch information
Showing
13 changed files
with
83 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Consola, BrowserReporter } from '../src' | ||
|
||
if (window.consola) { | ||
module.exports = window.consola | ||
} else { | ||
// Create new consola instance | ||
module.exports = window.consola = new Consola({ | ||
reporters: [ | ||
new BrowserReporter() | ||
] | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
if (global.consola) { | ||
module.exports = global.consola | ||
} else { | ||
const env = require('std-env') | ||
const { Consola, BasicReporter, FancyReporter } = require('../dist/consola.cjs.js') | ||
|
||
// Log level | ||
let level = env.debug ? 4 : 3 | ||
if (process.env['CONSOLA_LEVEL']) { | ||
level = parseInt(process.env['CONSOLA_LEVEL']) || level | ||
} | ||
|
||
// Create new consola instance | ||
module.exports = global.consola = new Consola({ | ||
level, | ||
reporters: [ | ||
env.minimalCLI | ||
? new BasicReporter() | ||
: new FancyReporter() | ||
] | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,13 @@ | ||
import env from 'std-env' | ||
import Consola from './consola' | ||
import { | ||
BasicReporter, | ||
FancyReporter, | ||
JSONReporter, | ||
WinstonReporter | ||
} from './reporters' | ||
export { | ||
Consola | ||
} from './consola' | ||
|
||
// Log level | ||
let level = env.debug ? 4 : 3 | ||
if (typeof process !== 'undefined' && process.env['CONSOLA_LEVEL']) { | ||
level = parseInt(process.env['CONSOLA_LEVEL']) | ||
} | ||
export { | ||
Types | ||
} from './types' | ||
|
||
// Create new consola instance | ||
const consola = new Consola({ | ||
level | ||
}) | ||
export { | ||
isLogObj | ||
} from './utils' | ||
|
||
// Add default reporter based on env | ||
if (env.minimalCLI) { | ||
consola.add(new BasicReporter()) | ||
} else { | ||
consola.add(new FancyReporter()) | ||
} | ||
|
||
Object.assign(consola, { | ||
Consola, | ||
BasicReporter, | ||
FancyReporter, | ||
JSONReporter, | ||
WinstonReporter | ||
}) | ||
|
||
export default consola | ||
export * from './reporters' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export default class BrowserReporter { | ||
constructor (options) { | ||
this.options = Object.assign({}, options) | ||
} | ||
|
||
log (logObj) { | ||
// TODO: Improve me | ||
console.log(logObj) // eslint-disable-line no-console | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export { default as BasicReporter } from './basic' | ||
export { default as BrowserReporter } from './browser' | ||
export { default as FancyReporter } from './fancy' | ||
export { default as JSONReporter } from './json' | ||
export { default as WinstonReporter } from './winston' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
export default { | ||
export const Types = { | ||
fatal: { | ||
level: 0, | ||
color: 'red' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters