Improve Logging (#1519)

Improve Logging

Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
Tilman Vatteroth 2021-09-28 22:06:35 +02:00 committed by GitHub
parent 1172a1d7b8
commit 0e512531a0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
41 changed files with 361 additions and 92 deletions

View file

@ -9,12 +9,15 @@ import { Overlay, Tooltip } from 'react-bootstrap'
import { Trans, useTranslation } from 'react-i18next'
import { v4 as uuid } from 'uuid'
import { ShowIf } from '../show-if/show-if'
import { Logger } from '../../../utils/logger'
export interface CopyOverlayProps {
content: string
clickComponent: RefObject<HTMLElement>
}
const log = new Logger('CopyOverlay')
export const CopyOverlay: React.FC<CopyOverlayProps> = ({ content, clickComponent }) => {
useTranslation()
const [showCopiedTooltip, setShowCopiedTooltip] = useState(false)
@ -27,9 +30,9 @@ export const CopyOverlay: React.FC<CopyOverlayProps> = ({ content, clickComponen
.then(() => {
setError(false)
})
.catch(() => {
.catch((error: Error) => {
setError(true)
console.error("couldn't copy")
log.error('Copy failed', error)
})
.finally(() => {
setShowCopiedTooltip(true)

View file

@ -10,6 +10,7 @@ import { useTranslation } from 'react-i18next'
import { ForkAwesomeIcon } from '../../fork-awesome/fork-awesome-icon'
import { ShowIf } from '../../show-if/show-if'
import { CopyOverlay } from '../copy-overlay'
import { Logger } from '../../../../utils/logger'
export interface CopyableFieldProps {
content: string
@ -17,6 +18,8 @@ export interface CopyableFieldProps {
url?: string
}
const log = new Logger('CopyableField')
export const CopyableField: React.FC<CopyableFieldProps> = ({ content, nativeShareButton, url }) => {
useTranslation()
const copyButton = useRef<HTMLButtonElement>(null)
@ -27,8 +30,8 @@ export const CopyableField: React.FC<CopyableFieldProps> = ({ content, nativeSha
text: content,
url: url
})
.catch((err) => {
console.error('Native sharing failed: ', err)
.catch((error) => {
log.error('Native sharing failed', error)
})
}, [content, url])