mirror of
https://github.com/oceanprotocol/market.git
synced 2024-11-15 09:44:53 +01:00
set ocen-lib-js log levels based on debug value
This commit is contained in:
parent
a8d8c95acb
commit
1ea70be80c
@ -3,6 +3,7 @@ import { FormikProps, connect } from 'formik'
|
|||||||
import debounce from 'lodash.debounce'
|
import debounce from 'lodash.debounce'
|
||||||
import omit from 'lodash.omit'
|
import omit from 'lodash.omit'
|
||||||
import isEqual from 'react-fast-compare'
|
import isEqual from 'react-fast-compare'
|
||||||
|
import { Logger } from '@oceanprotocol/lib'
|
||||||
|
|
||||||
export interface PersistProps {
|
export interface PersistProps {
|
||||||
name: string
|
name: string
|
||||||
@ -21,7 +22,7 @@ class PersistImpl extends React.Component<
|
|||||||
|
|
||||||
saveForm = debounce((data: FormikProps<any>) => {
|
saveForm = debounce((data: FormikProps<any>) => {
|
||||||
const dataToSave = this.omitIgnoredFields(data)
|
const dataToSave = this.omitIgnoredFields(data)
|
||||||
console.log('data tosave', dataToSave)
|
Logger.log('data to save', dataToSave)
|
||||||
if (this.props.isSessionStorage) {
|
if (this.props.isSessionStorage) {
|
||||||
window.sessionStorage.setItem(this.props.name, JSON.stringify(dataToSave))
|
window.sessionStorage.setItem(this.props.name, JSON.stringify(dataToSave))
|
||||||
} else {
|
} else {
|
||||||
@ -31,10 +32,10 @@ class PersistImpl extends React.Component<
|
|||||||
|
|
||||||
omitIgnoredFields = (data: FormikProps<any>) => {
|
omitIgnoredFields = (data: FormikProps<any>) => {
|
||||||
const { ignoreFields } = this.props
|
const { ignoreFields } = this.props
|
||||||
console.log('omit fiel', ignoreFields)
|
Logger.log('omitted fields', ignoreFields)
|
||||||
const { values, touched, errors } = data
|
const { values, touched, errors } = data
|
||||||
|
|
||||||
console.log('vale', values, omit(values, ignoreFields))
|
Logger.log('values', values, omit(values, ignoreFields))
|
||||||
return ignoreFields
|
return ignoreFields
|
||||||
? omit(
|
? omit(
|
||||||
{
|
{
|
||||||
|
@ -6,6 +6,8 @@ import React, {
|
|||||||
useState,
|
useState,
|
||||||
useEffect
|
useEffect
|
||||||
} from 'react'
|
} from 'react'
|
||||||
|
import { Logger } from '@oceanprotocol/lib'
|
||||||
|
import { LogLevel } from '@oceanprotocol/lib/dist/node/utils/Logger'
|
||||||
|
|
||||||
interface UserPreferencesValue {
|
interface UserPreferencesValue {
|
||||||
debug: boolean
|
debug: boolean
|
||||||
@ -52,6 +54,13 @@ function UserPreferencesProvider({
|
|||||||
setLocalStorage({ debug, currency })
|
setLocalStorage({ debug, currency })
|
||||||
}, [debug, currency])
|
}, [debug, currency])
|
||||||
|
|
||||||
|
// Set ocen-lib-js log levels, default: Error
|
||||||
|
useEffect(() => {
|
||||||
|
debug === true
|
||||||
|
? Logger.setLevel(LogLevel.Verbose)
|
||||||
|
: Logger.setLevel(LogLevel.Error)
|
||||||
|
}, [debug])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<UserPreferencesContext.Provider
|
<UserPreferencesContext.Provider
|
||||||
value={{ debug, currency, setDebug, setCurrency } as UserPreferencesValue}
|
value={{ debug, currency, setDebug, setCurrency } as UserPreferencesValue}
|
||||||
|
Loading…
Reference in New Issue
Block a user