mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-29 06:15:29 -04:00
Improve Logging (#1519)
Improve Logging Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
parent
1172a1d7b8
commit
0e512531a0
41 changed files with 361 additions and 92 deletions
|
@ -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)
|
||||
|
|
|
@ -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])
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue