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 omit from 'lodash.omit'
|
||||
import isEqual from 'react-fast-compare'
|
||||
import { Logger } from '@oceanprotocol/lib'
|
||||
|
||||
export interface PersistProps {
|
||||
name: string
|
||||
@ -21,7 +22,7 @@ class PersistImpl extends React.Component<
|
||||
|
||||
saveForm = debounce((data: FormikProps<any>) => {
|
||||
const dataToSave = this.omitIgnoredFields(data)
|
||||
console.log('data tosave', dataToSave)
|
||||
Logger.log('data to save', dataToSave)
|
||||
if (this.props.isSessionStorage) {
|
||||
window.sessionStorage.setItem(this.props.name, JSON.stringify(dataToSave))
|
||||
} else {
|
||||
@ -31,10 +32,10 @@ class PersistImpl extends React.Component<
|
||||
|
||||
omitIgnoredFields = (data: FormikProps<any>) => {
|
||||
const { ignoreFields } = this.props
|
||||
console.log('omit fiel', ignoreFields)
|
||||
Logger.log('omitted fields', ignoreFields)
|
||||
const { values, touched, errors } = data
|
||||
|
||||
console.log('vale', values, omit(values, ignoreFields))
|
||||
Logger.log('values', values, omit(values, ignoreFields))
|
||||
return ignoreFields
|
||||
? omit(
|
||||
{
|
||||
|
@ -6,6 +6,8 @@ import React, {
|
||||
useState,
|
||||
useEffect
|
||||
} from 'react'
|
||||
import { Logger } from '@oceanprotocol/lib'
|
||||
import { LogLevel } from '@oceanprotocol/lib/dist/node/utils/Logger'
|
||||
|
||||
interface UserPreferencesValue {
|
||||
debug: boolean
|
||||
@ -52,6 +54,13 @@ function UserPreferencesProvider({
|
||||
setLocalStorage({ 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 (
|
||||
<UserPreferencesContext.Provider
|
||||
value={{ debug, currency, setDebug, setCurrency } as UserPreferencesValue}
|
||||
|
Loading…
Reference in New Issue
Block a user