Unsuppress useful warnings in core. (#248)
This also temporarily removes `coreLogger`'s config from the public API One reason is that we don't have many logs that could benefit from suppressing (see diff) so the experimental API would not be useful to the user yet. Also, the default config was suppressing useful warnings. Those warnings _would_ have been dead-code-eliminated in production mode anyway, so having a separate config to suppress them in dev mode makes it confusing. Fixes P-171
This commit is contained in:
parent
88df1ef004
commit
a9910fecba
6 changed files with 30 additions and 36 deletions
|
@ -3,7 +3,6 @@ import ReactDOM from 'react-dom'
|
||||||
import studio from '@theatre/studio'
|
import studio from '@theatre/studio'
|
||||||
import {getProject} from '@theatre/core'
|
import {getProject} from '@theatre/core'
|
||||||
import {Scene} from './Scene'
|
import {Scene} from './Scene'
|
||||||
import {TheatreLoggerLevel} from '@theatre/shared/logger'
|
|
||||||
/**
|
/**
|
||||||
* This is a basic example of using Theatre for manipulating the DOM.
|
* This is a basic example of using Theatre for manipulating the DOM.
|
||||||
*
|
*
|
||||||
|
@ -16,13 +15,13 @@ studio.initialize()
|
||||||
ReactDOM.render(
|
ReactDOM.render(
|
||||||
<Scene
|
<Scene
|
||||||
project={getProject('Sample project', {
|
project={getProject('Sample project', {
|
||||||
experiments: {
|
// experiments: {
|
||||||
logging: {
|
// logging: {
|
||||||
internal: true,
|
// internal: true,
|
||||||
dev: true,
|
// dev: true,
|
||||||
min: TheatreLoggerLevel.TRACE,
|
// min: TheatreLoggerLevel.TRACE,
|
||||||
},
|
// },
|
||||||
},
|
// },
|
||||||
})}
|
})}
|
||||||
/>,
|
/>,
|
||||||
document.getElementById('root'),
|
document.getElementById('root'),
|
||||||
|
|
|
@ -61,7 +61,7 @@ export function getProject(id: string, config: IProjectConfig = {}): IProject {
|
||||||
return existingProject.publicApi
|
return existingProject.publicApi
|
||||||
}
|
}
|
||||||
|
|
||||||
const rootLogger = _coreLogger(config.experiments)
|
const rootLogger = _coreLogger()
|
||||||
const plogger = rootLogger.named('Project', id)
|
const plogger = rootLogger.named('Project', id)
|
||||||
|
|
||||||
if (process.env.NODE_ENV !== 'production') {
|
if (process.env.NODE_ENV !== 'production') {
|
||||||
|
|
|
@ -66,12 +66,10 @@ export default class Project {
|
||||||
readonly config: Conf = {},
|
readonly config: Conf = {},
|
||||||
readonly publicApi: TheatreProject,
|
readonly publicApi: TheatreProject,
|
||||||
) {
|
) {
|
||||||
this._logger = _coreLogger(config.experiments).named('Project', id)
|
this._logger = _coreLogger({logging: {dev: true}}).named('Project', id)
|
||||||
this._logger.traceDev('creating project')
|
this._logger.traceDev('creating project')
|
||||||
this.address = {projectId: id}
|
this.address = {projectId: id}
|
||||||
|
|
||||||
// remove when logger is understood
|
|
||||||
this._logger._kapow('this is a "kapow"')
|
|
||||||
const onDiskStateAtom = new Atom<ProjectState>({
|
const onDiskStateAtom = new Atom<ProjectState>({
|
||||||
ahistoric: {
|
ahistoric: {
|
||||||
ahistoricStuff: '',
|
ahistoricStuff: '',
|
||||||
|
@ -136,7 +134,7 @@ export default class Project {
|
||||||
`Project ${this.address.projectId} is already attached to studio ${this._studio.address.studioId}`,
|
`Project ${this.address.projectId} is already attached to studio ${this._studio.address.studioId}`,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
this._logger.warnDev(
|
console.warn(
|
||||||
`Project ${this.address.projectId} is already attached to studio ${this._studio.address.studioId}`,
|
`Project ${this.address.projectId} is already attached to studio ${this._studio.address.studioId}`,
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
|
@ -1,10 +1,7 @@
|
||||||
import {privateAPI, setPrivateAPI} from '@theatre/core/privateAPIs'
|
import {privateAPI, setPrivateAPI} from '@theatre/core/privateAPIs'
|
||||||
import Project from '@theatre/core/projects/Project'
|
import Project from '@theatre/core/projects/Project'
|
||||||
import type {ISheet} from '@theatre/core/sheets/TheatreSheet'
|
import type {ISheet} from '@theatre/core/sheets/TheatreSheet'
|
||||||
import type {
|
|
||||||
ITheatreLoggerConfig,
|
|
||||||
ITheatreLoggingConfig,
|
|
||||||
} from '@theatre/shared/logger'
|
|
||||||
import type {ProjectAddress} from '@theatre/shared/utils/addresses'
|
import type {ProjectAddress} from '@theatre/shared/utils/addresses'
|
||||||
import type {
|
import type {
|
||||||
ProjectId,
|
ProjectId,
|
||||||
|
@ -23,23 +20,23 @@ export type IProjectConfig = {
|
||||||
* The state of the project, as [exported](https://docs.theatrejs.com/in-depth/#exporting) by the studio.
|
* The state of the project, as [exported](https://docs.theatrejs.com/in-depth/#exporting) by the studio.
|
||||||
*/
|
*/
|
||||||
state?: $IntentionalAny
|
state?: $IntentionalAny
|
||||||
experiments?: IProjectConfigExperiments
|
// experiments?: IProjectConfigExperiments
|
||||||
}
|
}
|
||||||
|
|
||||||
export type IProjectConfigExperiments = {
|
// export type IProjectConfigExperiments = {
|
||||||
/**
|
// /**
|
||||||
* Defaults to using global `console` with style args.
|
// * Defaults to using global `console` with style args.
|
||||||
*
|
// *
|
||||||
* (TODO: check for browser environment before using style args)
|
// * (TODO: check for browser environment before using style args)
|
||||||
*/
|
// */
|
||||||
logger?: ITheatreLoggerConfig
|
// logger?: ITheatreLoggerConfig
|
||||||
/**
|
// /**
|
||||||
* Defaults:
|
// * Defaults:
|
||||||
* * `production` builds: console - error
|
// * * `production` builds: console - error
|
||||||
* * `development` builds: console - error, warning
|
// * * `development` builds: console - error, warning
|
||||||
*/
|
// */
|
||||||
logging?: ITheatreLoggingConfig
|
// logging?: ITheatreLoggingConfig
|
||||||
}
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Theatre project
|
* A Theatre project
|
||||||
|
|
|
@ -145,13 +145,13 @@ export default class Sequence {
|
||||||
this.pause()
|
this.pause()
|
||||||
if (process.env.NODE_ENV !== 'production') {
|
if (process.env.NODE_ENV !== 'production') {
|
||||||
if (typeof position !== 'number') {
|
if (typeof position !== 'number') {
|
||||||
this._logger.errorDev(
|
console.error(
|
||||||
`value t in sequence.position = t must be a number. ${typeof position} given`,
|
`value t in sequence.position = t must be a number. ${typeof position} given`,
|
||||||
)
|
)
|
||||||
position = 0
|
position = 0
|
||||||
}
|
}
|
||||||
if (position < 0) {
|
if (position < 0) {
|
||||||
this._logger.errorDev(
|
console.error(
|
||||||
`sequence.position must be a positive number. ${position} given`,
|
`sequence.position must be a positive number. ${position} given`,
|
||||||
)
|
)
|
||||||
position = 0
|
position = 0
|
||||||
|
@ -231,7 +231,7 @@ export default class Sequence {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (range[1] > sequenceDuration) {
|
if (range[1] > sequenceDuration) {
|
||||||
this._logger.warnDev(
|
console.warn(
|
||||||
`Argument conf.range[1] in sequence.play(conf) cannot be longer than the duration of the sequence, which is ${sequenceDuration}s. ${JSON.stringify(
|
`Argument conf.range[1] in sequence.play(conf) cannot be longer than the duration of the sequence, which is ${sequenceDuration}s. ${JSON.stringify(
|
||||||
range[1],
|
range[1],
|
||||||
)} given.`,
|
)} given.`,
|
||||||
|
|
|
@ -239,7 +239,7 @@ export default class TheatreSequence implements ISequence {
|
||||||
return priv.play(conf)
|
return priv.play(conf)
|
||||||
} else {
|
} else {
|
||||||
if (process.env.NODE_ENV !== 'production') {
|
if (process.env.NODE_ENV !== 'production') {
|
||||||
priv._logger.warnDev(
|
console.warn(
|
||||||
`You seem to have called sequence.play() before the project has finished loading.\n` +
|
`You seem to have called sequence.play() before the project has finished loading.\n` +
|
||||||
`This would **not** a problem in production when using '@theatre/core', since Theatre loads instantly in core mode. ` +
|
`This would **not** a problem in production when using '@theatre/core', since Theatre loads instantly in core mode. ` +
|
||||||
`However, when using '@theatre/studio', it takes a few milliseconds for it to load your project's state, ` +
|
`However, when using '@theatre/studio', it takes a few milliseconds for it to load your project's state, ` +
|
||||||
|
|
Loading…
Reference in a new issue