Closed prescience-data closed 2 years ago
Thank you for this feedback. I will take a look and get this fixed.
@prescience-data I unable to reproduce this issue.
If I use either in the options
{
console: true,
}
or
{
console: {
enable: true
integrations: ['log', 'error']
}
}
I get logs sent to both the browser console and to LogDNA.
Can you try retesting when you have a chance?
const options: LogDNAOptions = {
hostname: env.APP_NAME,
enableIpAddress: env.LOGDNA_ENABLE_IP_ADDRESS,
debug: env.LOGDNA_DEBUG,
enableStacktrace: true,
console: true,
globalErrorHandlers: true,
tags: ["frontend"]
}
logdna.init(env.LOGDNA_INGESTION_KEY, { ...options })
Are any of these others potentially conflicting with the console
property?
This is the only way I've been able to get it to output to console is to set console: false
and use a custom hook:
const hooks: LogHooks = {
beforeSend: [
({ message, level, lineContext }) => {
if (env.LOGDNA_CONSOLE) {
switch (level) {
case "error":
case "fatal":
console.error(message, lineContext)
break
case "warn":
console.warn(message, lineContext)
break
default:
console.log(message, lineContext)
}
}
return { message, level, lineContext }
}
]
}
logdna.init(env.LOGDNA_INGESTION_KEY, { ...options, hooks })
For clarity, I am using
logdna.warn("foo")
instead of the native
console.warn("foo")
When you tested above, I assume you were using the native console?
Oh, ok I know whats going on. I will have this fixed up shortly.
:tada: This issue has been resolved in version 2.0.3 :tada:
The release is available on:
Your semantic-release bot :package::rocket:
@TerryMooreII
Bumped to latest, but still not seeing regular console output.
Can you see any issues with this workflow?
{
"dependencies": {
"@logdna/browser": "^2.0.3"
}
}
export const [DEBUG_LEVEL, INFO_LEVEL, WARN_LEVEL, ERROR_LEVEL] = [
"debug",
"info",
"warn",
"error"
] as const
export const logLevels = [
DEBUG_LEVEL,
INFO_LEVEL,
WARN_LEVEL,
ERROR_LEVEL
] as const
export type LogLevel = typeof logLevels[number]
const options: LogDNAOptions = toLogDNAOptions({
hostname: env.APP_NAME,
enableIpAddress: env.LOGDNA_ENABLE_IP_ADDRESS,
enableStacktrace: true,
console: true,
globalErrorHandlers: true
})
logdna.init(env.LOGDNA_INGESTION_KEY, options)
export const debug = (message: Serializable, context?: LogContext): void =>
logdna.log(serialize(message), parse(context), DEBUG_LEVEL)
export const warn = (message: Serializable, context?: LogContext): void =>
logdna.log(serialize(message), parse(context), WARN_LEVEL)
Just trying out the new
v2.0.1
and noticed that despite enablingthe logger is no longer sending lines to console output.