Skip to content

Commit

Permalink
Replace all usages of console and the old logger, make mobile work we…
Browse files Browse the repository at this point in the history
…ll with luxon
  • Loading branch information
islathehut committed May 15, 2024
1 parent ca4b0e3 commit d5fecbd
Show file tree
Hide file tree
Showing 88 changed files with 3,371 additions and 2,258 deletions.
26 changes: 16 additions & 10 deletions packages/backend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"@types/crypto-js": "^4.0.2",
"@types/express": "^4.17.9",
"@types/jest": "28.1.8",
"@types/luxon": "^3.3.0",
"@types/luxon": "^3.4.2",
"@types/mock-fs": "^4.13.1",
"@types/node": "18.11.9",
"@types/node-fetch": "^2.5.11",
Expand Down Expand Up @@ -122,7 +122,7 @@
"joi": "^17.8.1",
"level": "8.0.0",
"libp2p": "0.42.2",
"luxon": "^1.11.4",
"luxon": "^3.4.4",
"multiaddr": "^10.0.1",
"orbit-db": "0.29.0",
"orbit-db-access-controllers": "^0.4.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { createLibp2pAddress } from '@quiet/common'
import { lib } from 'crypto-js'
import { createLogger } from '../common/logger'

const logger = createLogger('test:connectionsManager')
const logger = createLogger('connectionsManager:test')

jest.setTimeout(100_000)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { sleep } from '../common/sleep'
import fs from 'fs'
import { createLogger } from '../common/logger'

const logger = createLogger('test:bigFiles')
const logger = createLogger('bigFiles:test')

jest.setTimeout(200_000)
describe('IpfsFileManagerService', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/nest/libp2p/process-in-chunks.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { TestModule } from '../common/test.module'
import { Test, TestingModule } from '@nestjs/testing'
import { createLogger } from '../common/logger'

const logger = createLogger('test:processInChunksService')
const logger = createLogger('processInChunksService:test')

describe('ProcessInChunks', () => {
let module: TestingModule
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/nest/storage/storage.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ import { OrbitDb } from './orbitDb/orbitDb.service'
import { UserProfileStore } from './userProfile/userProfile.store'
import { createLogger } from '../common/logger'

const logger = createLogger('test:storageService')
const logger = createLogger('storageService:test')

const filename = fileURLToPath(import.meta.url)
const dirname = path.dirname(filename)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { TorControlAuthType } from '../tor/tor.types'
import { createLibp2pAddress } from '@quiet/common'
import { createLogger } from '../common/logger'

const logger = createLogger('test:websocketOverTor')
const logger = createLogger('websocketOverTor:test')

jest.setTimeout(120000)

Expand Down
32 changes: 15 additions & 17 deletions packages/desktop/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions packages/desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
"build:renderer:prod": "webpack --config webpack/webpack.config.renderer.prod.js",
"postBuild": "node scripts/postBuild.js",
"prestart": "npm run build:main",
"start": "cross-env DEBUG='backend*,quiet*,state-manager*,desktop*,utils*,libp2p:websockets:listener:backend,libp2p:connection-manager:auto-dialler' npm run start:renderer",
"start": "cross-env DEBUG='backend*,quiet*,state-manager*,desktop*,utils*,identity*,common*,libp2p:websockets:listener:backend,libp2p:connection-manager:auto-dialler' npm run start:renderer",
"start:main": "cross-env NODE_ENV=development electron .",
"start:renderer": "cross-env NODE_ENV=development webpack-dev-server --config webpack/webpack.config.renderer.dev.js",
"storybook": "export NODE_OPTIONS=--openssl-legacy-provider && start-storybook -p 6006",
Expand All @@ -141,6 +141,7 @@
"electron-updater": "^5.0.1",
"get-port": "^5.1.1",
"keymirror": "0.1.1",
"luxon": "^3.4.4",
"pkijs": "^3.0.8",
"react-markdown": "^6.0.3",
"react-qr-code": "^2.0.11",
Expand Down Expand Up @@ -184,7 +185,7 @@
"@types/jest": "^26.0.23",
"@types/keymirror": "^0.1.1",
"@types/lodash": "^4.14.169",
"@types/luxon": "^1.25.0",
"@types/luxon": "^3.4.2",
"@types/node": "16.11.7",
"@types/ps-node": "^0.1.0",
"@types/ramda": "^0.27.31",
Expand Down Expand Up @@ -230,7 +231,6 @@
"js-yaml": "4.1.0",
"lint-staged": "^15.2.2",
"local-cypress": "1.2.6",
"luxon": "^1.11.4",
"mathjax-full": "^3.2.2",
"node-polyfill-webpack-plugin": "^2.0.1",
"ramda": "^0.26.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ import { userNameField } from '../../forms/fields/createUserFields'

import { parseName } from '@quiet/common'

import { createLogger } from '../../logger'

const logger = createLogger('changeUsername:component')

const PREFIX = 'ChangeUsername-'

const classes = {
Expand Down Expand Up @@ -174,7 +178,7 @@ export const ChangeUsername: React.FC<ChangeUsernameProps> = ({
const onSubmit = useCallback(
(values: ChangeUserNameValues) => {
if (errors.userName) {
console.error('Cannot submit form with errors')
logger.error('Cannot submit form with errors')
return
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import { ComponentStory, ComponentMeta } from '@storybook/react'

import { withTheme } from '../../../storybook/decorators'
import CreateChannelComponent, { CreateChannelProps } from './CreateChannelComponent'
import { createLogger } from '../../../logger'

const logger = createLogger('createChannel:stories')

const Template: ComponentStory<typeof CreateChannelComponent> = args => {
return <CreateChannelComponent {...args} />
Expand All @@ -13,7 +16,7 @@ export const Component = Template.bind({})
const args: CreateChannelProps = {
open: true,
createChannel: function (name: string): void {
console.log('creating channel: ', name)
logger.info('creating channel: ', name)
},
handleClose: function (): void {},
clearErrorsDispatch: function (): void {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ import { modalsActions } from '../../../sagas/modals/modals.slice'

import { getFactory, identity, publicChannels } from '@quiet/state-manager'

import { createLogger } from '../../../logger'

const logger = createLogger('createChannel:test')

describe('Add new channel', () => {
let socket: MockedSocket

Expand Down Expand Up @@ -50,7 +54,7 @@ describe('Add new channel', () => {
async () =>
await waitFor(() => {
user.click(screen.getByText('Create Channel')).catch(e => {
console.error(e)
logger.error(e)
})
})
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import { useModal } from '../../../containers/hooks'
import { ModalName } from '../../../sagas/modals/modals.types'
import { flushSync } from 'react-dom'
import { generateChannelId } from '@quiet/common'
import { createLogger } from '../../../logger'

const logger = createLogger('createChannel')

export const CreateChannel = () => {
const dispatch = useDispatch()
Expand Down Expand Up @@ -46,7 +49,7 @@ export const CreateChannel = () => {
// Clear errors
clearErrors()
if (!user) {
console.error('No identity found')
logger.error('No identity found')
dispatch(
errors.actions.addError({
type: SocketActionTypes.CREATE_CHANNEL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import { useModal } from '../../../containers/hooks'

import DeleteChannelComponent, { DeleteChannelProps } from './DeleteChannelComponent'

import { createLogger } from '../../../logger'

const logger = createLogger('deleteChannel:stories')

const Template: ComponentStory<typeof DeleteChannelComponent> = args => {
return <DeleteChannelComponent {...args} />
}
Expand All @@ -15,7 +19,7 @@ export const Component = Template.bind({})
const args: ReturnType<typeof useModal> & DeleteChannelProps = {
channelName: 'general',
deleteChannel: () => {
console.log('deleting channel')
logger.info('deleting channel')
},
open: true,
// @ts-expect-error
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import Icon from '../../ui/Icon/Icon'
import dropFiles from '../../../static/images/dropFiles.svg'
import { DropTargetMonitor, useDrop } from 'react-dnd'
import { NativeTypes } from 'react-dnd-html5-backend'
import { createLogger } from '../../../logger'

const logger = createLogger('dropZone:component')

const StyledDropZoneComponent = styled(Grid)(() => ({
position: 'relative',
Expand Down Expand Up @@ -55,7 +58,7 @@ export const DropZoneComponent: React.FC<DropZoneComponentProps> = ({ children,
if (fs.statSync(item.files[0].path).isDirectory()) return
} catch (e) {
// See: https://github.com/react-dnd/react-dnd/issues/3458
console.error('drop error: ', e.message)
logger.error('drop error: ', e)
return
}
handleFileDrop(item)
Expand All @@ -67,7 +70,7 @@ export const DropZoneComponent: React.FC<DropZoneComponentProps> = ({ children,
collect: (monitor: DropTargetMonitor) => {
const item: any = monitor.getItem()
if (item) {
console.log('collect', item.files, item.items)
logger.info('collect', item.files, item.items)
}

return {
Expand Down
Loading

0 comments on commit d5fecbd

Please sign in to comment.