-
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: expose
createConsola
and named exports
- Loading branch information
Showing
9 changed files
with
89 additions
and
98 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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { createConsola } from "./consola"; | ||
import BrowserReporter from "./reporters/browser"; | ||
|
||
export * from "./index.shared"; | ||
|
||
function _createConsola() { | ||
const consola = createConsola({ | ||
reporters: [new BrowserReporter({})], | ||
}); | ||
return consola; | ||
} | ||
|
||
export const consola = (globalThis.consola = | ||
globalThis.consola || _createConsola()); | ||
|
||
export default consola; |
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,5 @@ | ||
export { Consola, createConsola } from "./consola"; | ||
export { Types } from "./log.types"; | ||
export { LogLevels } from "./log.levels"; | ||
export { isLogObj } from "./utils"; | ||
export { assignGlobalConsola } from "./utils/global"; |
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,7 +1,38 @@ | ||
export { default as Consola } from "./consola"; | ||
export { default as Types } from "./log.types"; | ||
export { LogLevels } from "./log.levels"; | ||
export { isLogObj } from "./utils"; | ||
export { assignGlobalConsola } from "./utils/global"; | ||
import { isDebug, isTest, isCI } from "std-env"; | ||
import { LogLevels } from "./log.levels"; | ||
import type { LogLevel } from "./types"; | ||
import { BasicReporter, FancyReporter } from "./reporters"; | ||
import { createConsola } from "./index.shared"; | ||
|
||
export * from "./reporters"; | ||
export * from "./index.shared"; | ||
|
||
function _createConsola() { | ||
// Log level | ||
let level = _getDefaultLogLevel(); | ||
if (process.env.CONSOLA_LEVEL) { | ||
level = Number.parseInt(process.env.CONSOLA_LEVEL) || level; | ||
} | ||
|
||
// Create new consola instance | ||
const consola = createConsola({ | ||
level: level as LogLevel, | ||
reporters: [isCI || isTest ? new BasicReporter({}) : new FancyReporter({})], | ||
}); | ||
|
||
return consola; | ||
} | ||
|
||
function _getDefaultLogLevel() { | ||
if (isDebug) { | ||
return LogLevels.Debug; | ||
} | ||
if (isTest) { | ||
return LogLevels.Warn; | ||
} | ||
return LogLevels.Info; | ||
} | ||
|
||
export const consola = (globalThis.consola = | ||
globalThis.consola || _createConsola()); | ||
|
||
export default consola; |
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