Better Stack JavaScript client
๐ฃ Logtail is now part of Better Stack. Learn more โ
Experience SQL-compatible structured log management based on ClickHouse. Learn more โ
Please let us know at [email protected]. We're happy to help!
Better Stack JavaScript client
Home Page: https://betterstack.com/logs
License: ISC License
๐ฃ Logtail is now part of Better Stack. Learn more โ
Experience SQL-compatible structured log management based on ClickHouse. Learn more โ
Please let us know at [email protected]. We're happy to help!
The scenario is this:
Is this possible without having to add a second logger just for Logtail?
Every line that's logged has an extra string added to it. Everything starting with the 9 and ending with the 48. How do I get rid of this?
`
2021-11-13 14:34:50.983 [qa] [INFO] 9 ../task/node_modules/@logtail/winston/dist/cjs/winston.js 48 --> POST /api/stripe
2021-11-13 14:34:51.219 [qa] [INFO] 9 ../task/node_modules/@logtail/winston/dist/cjs/winston.js 48 Processing Stripe Event: invoice.created.
2021-11-13 14:34:51.268 [qa] [INFO] 9 ../task/node_modules/@logtail/winston/dist/cjs/winston.js 48 <-- [204] POST /api/stripe 286ms
`
These are the Winston options I have set:
winston.createLogger({ level: 'debug', // change to info for prod? format: winston.format.combine( winston.format.colorize(), winston.format.align(), winston.format.splat(), winston.format.timestamp({ format: customTimeStamp() }), winston.format.printf(customFormat), winston.format.errors({ stack: true }), //winston.format.json() use for non-local? ) })
Custom format:
const customFormat = log => { const pattern = /(error|warn|info|http|verbose|debug|silly)/s let level = log.level.match(pattern) if (level) { level = log.level.replace(pattern, level[0].toUpperCase()) } return log.stack ?
${log.timestamp} [${level}]: ${log.message}\n${log.stack}:
${log.timestamp} [${level}]: ${log.message} }
Hello.
I tried to install and setup this package on legacy code using Node.js 8.17.0
No surprise, it does'nt work! (as usual) because of @msgpack/msgpack
needing Node v10 at least. (for async
did not exists)
Do you have any solution to make it works in my situation ?
Also, it should be good to add Node.js requirements
section into README file
Thank you ๐
Hi! I am playing around with a Next.js app where I am trialling use of Logtail using the Winston logger for the backend calls.
The logs are coming across fine, but the context.runtime.file_string
is defaulting to the module file i.e. the value resolves to ../../../@logtail/winston/dist/cjs/winston.js
for each call.
I am hoping to update this to the current meta for the file name and line number. Are there any examples for how this works? I have been looking at the docs but am still unable to adjust to context metadata from that example.
Full disclosure: this seems like a misunderstanding of how the configuration works for Winston, given that the source code looks to simply destructure the meta
from a Winston LogEntry
type and I may also be failing to pinpoint the correct overrides needed from Winston itself.
Hi! I'm trying to set up this library with my Next.js app.
Here's my logger.ts
file, which I'm planning to import in my app to log events:
import { Browser as LogtailBrowser } from "@logtail/js";
import { Node as LogtailNode } from "@logtail/js"
const logClient = new LogtailBrowser(process.env.NEXT_PUBLIC_LOGTAIL_TOKEN)
const logServer = new LogtailNode(process.env.NEXT_PUBLIC_LOGTAIL_TOKEN)
export { logClient, logServer }
Now when I'm running my app, I am getting a warning:
warn - ./node_modules/@logtail/node/dist/es6/context.js
Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
Import trace for requested module:
./node_modules/@logtail/node/dist/es6/node.js
./node_modules/@logtail/node/dist/es6/index.js
./node_modules/@logtail/js/dist/es6/index.js
./logger/logger.ts
Can you tell me what that means, and how do I fix it?
Hey!
I saw y'all have been active on this repo lately, so wanted to make sure I raised this :)
tl;dr this library should offer support for using logtail in modern serverless environments like Cloudflare Workers.
I forked your node logger to do this, and have been using it in our product, you can see the changes here: master...magic-circle-studio:logtail-js-cfworker:master, and you can play with it on NPM here: @magiccircle/logtail-cfworker
Of course, it was just a quick and dirty have, and I don't really want to be maintaining a fork โ but it does work nicely so far.
My suggestion is that you introduce a new package, like node
or browser
, which is designed to run in serverless environments. You could perhaps call it "edge" or "workers". Then, I could use it like @logtail/edge
.
As you can see, there isn't really anything new to add to support these environments โ it's more a matter of slightly switching types and avoiding using node-specific libraries like fs
.
Let me know if you have any thoughts!
I simply copied the script tag into the head.
<script src="https://unpkg.com/@logtail/[email protected]/dist/umd/logtail.js"></script>The window has no attribute Logtail and the console shows the following error:
Does anyone have experience with using logtail with cdn?
Thanks!
I've been exploring logtail and the functionality looks good for my use case. However when I tried to install @logtail/node
I ran into a typescript compilation issue with babel. I can fix this issue by additionally specifying dependencies for @babel/core
, @babel/generator
, @babel/template
, @types/babel__generator
, @types/bablel__template
but I would prefer not having to do that.
Typescript version: 4.6.3 (I tried on other typescript versions as well but to no avail)
Logtail version: 0.3.1
tsconfig.json:
{
"compilerOptions": {
"outDir": "build",
"rootDir": "src",
"esModuleInterop": true,
"lib": ["es2020"],
"module": "commonjs",
"target": "es2019",
"alwaysStrict": true,
"noImplicitAny": true,
"removeComments": true,
"sourceMap": true,
},
"include": ["src/**/*.ts"],
"exclude": ["build", "node_modules"],
"watchOptions": {
"watchFile": "useFsEvents",
"watchDirectory": "useFsEvents",
"fallbackPolling": "dynamicPriority",
"synchronousWatchDirectory": true,
"excludeDirectories": ["./node_modules", "./build"]
},
}
dependencies:
"dependencies": {
"express": "^4.18.1",
"express-validator": "^6.14.0",
"http-errors": "^2.0.0",
"http-status-codes": "^2.2.0",
"source-map-support": "^0.5.21",
"uuid": "^8.3.2",
"@logtail/node": "^0.3.1"
},
"devDependencies": {
"@types/express": "^4.17.12",
"@types/express-serve-static-core": "^4.17.21",
"@types/http-errors": "^1.8.2",
"@types/morgan": "^1.7.37",
"@types/node": "^17.0.25",
"@typescript-eslint/eslint-plugin": "^5.19.0",
"@typescript-eslint/parser": "^5.19.0",
"eslint": "^8.14.0",
"eslint-plugin-import": "^2.26.0",
"tsc-watch": "^5.0.3",
"typescript": "^4.6.3"
}
Hi. Thank you for your work on this library!
I have a Next.js project where I'm using this library. But when I include it, my console gets spammed with the following message
./node_modules/@logtail/node/dist/es6/context.js
Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
Thanks for looking into this!
Have any questions? Please explore the Logtail documentation or contact our support.
node_modules/@logtail/node/dist/cjs/context.js:75
if (argv[i].startsWith('-')) {
^
TypeError: argv[i].startsWith is not a function
at mainFileName (?/node_modules/@logtail/node/dist/cjs/context.js:75:21)
at Object. (?/node_modules/@logtail/node/dist/cjs/context.js:9:18)
at Module._compile (node:internal/modules/cjs/loader:1226:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1280:10)
at Module.load (node:internal/modules/cjs/loader:1089:32)
at Module._load (node:internal/modules/cjs/loader:930:12)
at Module.require (node:internal/modules/cjs/loader:1113:19)
at require (node:internal/modules/cjs/helpers:103:18)
at Object. (?/node_modules/@logtail/node/dist/cjs/node.js:10:19)
at Module._compile (node:internal/modules/cjs/loader:1226:14)
This recheck broke the lib in every use I was able to test it on.
When developing locally I don't really need to send logging data to Logtail. It would be nice to be able to set the token to null
and have it just silently continue instead of throwing. null
being be different from undefined
, which could have been unintentional.
Is there way convenient way to do this already?
Hi
This problem of invalid dependency in logtail/winston trigger failure during npm ci
command execution and breaks deploy process:
npm ci
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: @logtail/[email protected]
npm ERR! Found: @logtail/[email protected]
npm ERR! node_modules/@logtail/node
npm ERR! @logtail/node@"^0.3.3" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer @logtail/node@"^0.2.0" from @logtail/[email protected]
npm ERR! node_modules/@logtail/winston
npm ERR! @logtail/winston@"^0.3.3" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: @logtail/[email protected]
npm ERR! node_modules/@logtail/node
npm ERR! peer @logtail/node@"^0.2.0" from @logtail/[email protected]
npm ERR! node_modules/@logtail/winston
npm ERR! @logtail/winston@"^0.3.3" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
Tested with node v18.14.1 with @logtail/[email protected] and @logtail/[email protected]
For now i'm forced to use logtail/[email protected] version.
Suppose I have a file named utils/logging.ts
containing:
export const log = (message, context) => {
logtail.info(message, context)
}
If I import and call log('Hello')
from a file named foo.js
, the context.runtime.file
is set to utils/logging.js
. I wanted it to be foo.js
instead.
Hello,
Is there any planned support for react native? The standard node library does not currently work for react native apps due to its dependency on path
, and I couldn't find any documentation on react native integrations.
For now, we have had to resort to firing off requests via http, and while this method does work, it is messier than using the library directly.
Thanks!
If I want my logs on localhost to just log and not send anything to betterstack (i.e. just act as console log) how do i do that
Currently, @logtail/edge
shows a warning if the logger is created without an execution context, and sends a message to Betterstack as well. I couldn't find a way to suppress it.
It'd be nice to have an option to manually suppress this warning. Another approach is determining whether the runtime is Cloudflare Workers (like here) and showing the warning only if it is.
As a temporary workaround I have to mock an execution context object as follows, so the warning doesn't come up.
export const logger = new Logtail("token")
.withExecutionContext({
waitUntil() {},
passThroughOnException() {},
});
Hi all, I'm seeing this error message, do you have any idea what the cause could be?
Error: Forbidden
at Node.sync [as _sync] (/Users/ryenbeatty/Code/project/node_modules/@logtail/node/dist/cjs/node.js:28:19)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
My config:
import { Browser, Node } from '@logtail/js'
const clientLogger = new Browser(process.env.NEXT_PUBLIC_LOGTAIL_SOURCE_TOKEN)
const serverLogger = new Node(process.env.NEXT_PUBLIC_LOGTAIL_SOURCE_TOKEN)
export { clientLogger, serverLogger }
When I do my first contribution for this repository I regret 2 small things
I thinks github actions must be set in order to do that.
await logtail.flush()
v0.4.0 does not properly resolve. We caught this in a jest test of ours that confirms we invoke logtail.flush()
when shutting down the server. This issue did not occur in logtail
v0.3.0.
Isolated reproducible code:
import { Logtail } from "@logtail/node";
it("flushes the batched Logtail logs", async () => {
const logtail = new Logtail("123");
await logtail.flush()
});
Warning for logtail v0.4.0:
Jest did not exit one second after the test run has completed.
'This usually means that there are asynchronous operations that weren't stopped in your tests.
Consider running Jest with `--detectOpenHandles` to troubleshoot this issue.
No warning for logtail v0.3.0.
To be clear, this is NOT an issue about compatibility with jest
. Rather, jest
is merely an easy way for us to catch this Logtail bug that occurs independently.
Hi
Since I migrated from logzio to logtail, I encounter a lot of log like this:
2023-03-25T11:37:50+01:00 Error: Unauthorized
2023-03-25T11:37:50+01:00 at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
2023-03-25T11:37:50+01:00 at Node.sync [as _sync] (/home/bas/app_f4b3548e-31fe-46b4-8dfc-502f72a8b749/node_modules/@logtail/node/dist/cjs/node.js:28:19)
2023-03-25T11:37:50+01:00 at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
2023-03-25T11:37:50+01:00 Error: Unauthorized
2023-03-25T11:37:50+01:00 at async handler (/home/bas/app_f4b3548e-31fe-46b4-8dfc-502f72a8b749/node_modules/@logtail/tools/dist/cjs/throttle.js:34:37)
2023-03-25T11:37:50+01:00 at Node.sync [as _sync] (/home/bas/app_f4b3548e-31fe-46b4-8dfc-502f72a8b749/node_modules/@logtail/node/dist/cjs/node.js:28:19)
2023-03-25T11:37:50+01:00 at async handler (/home/bas/app_f4b3548e-31fe-46b4-8dfc-502f72a8b749/node_modules/@logtail/tools/dist/cjs/throttle.js:34:37
The stack seems to say it's a problem from logtail library and it match the apparition of this kind of messages and my migration to logtail.
Despite this problem it seems I got all my logs in the logtail dashboard.
Maybe v0.3.3 fix the problem but I can test it due to peer dep issue (I created another issue)
Thank you for your support ;-)
First of all, I've just started using Logtail and think it's great.
One annoying thing I've found working with the logger from @logtail/node
is the Context
type:
export declare type ContextKey = string | number | boolean | Date | null;
export declare type Context = {
[key: string]: ContextKey | Context;
};
It is too strict to be able to work with conveniently. Some of the issues I've found:
undefined
fieldsstring[]
or object[]
)Error
unknown
)It would be great if Logtail could parse/sanitize these types internally as it would improve the DX a lot. Support for undefined
, arrays, and try/catch errors (unknown
type) is highest prio I'd say, as typed errors can be logged as the message argument.
I saw that there was a PR to sanitize logs, so perhaps some of this is already supported but not reflected in the ContextKey
type?
Here's a Stackblitz where I demostrate some of the issues:
https://stackblitz.com/edit/nestjs-typescript-starter-hzo1qb?file=demo.ts
Hey folks,
I just saw there's a minor version upgrade but don't see any release notes. How can I know if this upgrade will break my application? Either of these locations for release notes would be helpful as a consumer ๐
Hey,
hope you're doing well!
I tried to use the Winston LogtailTransport but I have some Typing issues.
Argument of type 'LogtailTransport' is not assignable to parameter of type 'TransportStream'.
Type 'LogtailTransport' is missing the following properties from type 'TransportStream': writable, writableEnded, writableFinished, writableHighWaterMark, and 29 more.
Some code ton reproduce this:
import * as winston from 'winston';
import * as Transport from 'winston-transport';
// Logtail -> https://logtail.com
import { Logtail } from '@logtail/node';
import { LogtailTransport } from '@logtail/winston';
const logtail = new Logtail('logtail-source-token');
const transports: Transport[] = [];
transports.push(new LogtailTransport(logtail));
const logger = winston.createLogger({
transports,
silent: process.env.NODE_ENV === 'test',
});
If I change the import of winston-transport
in winston.ts to import * as Transport from "winston-transport";
.
Maybe it's a tsconfig with compatibility with old module system but I think there is a lot of project that have this configuration.
Thanks for your help, happy to help debug this.
EDIT:
in tsconfig, I added some config to make it works. Maybe worth documenting this ๐
"moduleResolution": "node",
"esModuleInterop": true
We're having an issue where there are some fields that should never get logged externally. Let's say for example that there's a sensitive field "social-security-number
" and we wanted to ensure that never reaches logtail.
What is the recommended method for scrubbing out data like this at the library level before it ever reaches the network?
Hey,
I'm working on a Remix app, and trying to add logging using the @logtail/js
package as we need to log from the server actions in Node, and directly from the browser.
The server aspect is working perfectly, but as soon as I try to add client-side logging I get the following error in the console:
Remix has a convention of adding a .server.ts
suffix to files which should only be included in the server bundles, which is what I've done when using import { Node as Logtail } from '@logtail/js'
so I don't believe there is any server specific logic leaking into the client bundle.
The error only appears when I include a React context provider which I've setup for sharing the logger instance to any of my React components in the UI:
import { createContext, useContext, useMemo } from 'react'
import { Browser as Logtail } from '@logtail/js'
type Context = {
log: Logtail
}
const LogtailContext = createContext<Context | null>(null)
export const useLogtail = () => {
const context = useContext(LogtailContext)
if (context == null) throw Error('Use inside LogtailProvider')
return context
}
type Props = {
children: React.ReactNode
sourceToken: string
}
export const LogtailProvider = ({ sourceToken, children }: Props) => {
const log = useMemo(() => {
return new Logtail(sourceToken)
}, [sourceToken])
return (
<LogtailContext.Provider
value={{
log,
}}
>
{children}
</LogtailContext.Provider>
)
}
Any ideas what's happening? We're on v0.3.1 if it helps!
Thanks in advance
Currently error objects are stripped to only name
, message
and stack
properties.
this creates an issue when logging a class that inherits from the Error
class, all other properties and metadata data added to the custom class are lost.
I would like to propose to use the serialize-error library in order to serialize errors. I am not sure if this is possible since this will add a dependency to the project
Node.js Version: 20.5.1
Package Version: @logtail/node 0.4.6
(from npm)
After sending the log data, following console error appears.
(node:3878) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit
at _addListener (node:events:588:17)
at TLSSocket.addListener (node:events:606:10)
at Readable.on (node:internal/streams/readable:904:35)
at TLSSocket._wrapHandle (node:_tls_wrap:674:8)
at TLSSocket.reinitializeHandle (node:_tls_wrap:683:22)
at internalConnectMultiple (node:net:1123:30)
at Timeout.internalConnectMultipleTimeout (node:net:1687:3)
at listOnTimeout (node:internal/timers:575:11)
at process.processTimers (node:internal/timers:514:7)
When messages get batched and dispatched together, they end up with the same timestamp, which causes them to potentially appear in the wrong order on logtail.com.
Hello!
I'm using Logtail and just noticed an error on trying to log some metadata based on objects in my app that have circular references. This is the stack trace:
RangeError: Maximum call stack size exceeded
at /my_app/node_modules/@logtail/node/src/node.ts:104:37
at Array.forEach (<anonymous>)
at Node.sanitizeForEncoding (/my_app/node_modules/@logtail/node/src/node.ts:104:29)
at /my_app/node_modules/@logtail/node/src/node.ts:108:29
at Array.forEach (<anonymous>)
at Node.sanitizeForEncoding (/my_app/node_modules/@logtail/node/src/node.ts:104:29)
at /my_app/node_modules/@logtail/node/src/node.ts:108:29
at Array.forEach (<anonymous>)
at Node.sanitizeForEncoding (/my_app/node_modules/@logtail/node/src/node.ts:104:29)
at /my_app/node_modules/@logtail/node/src/node.ts:100:39
That links to this piece of code, which is ignoring possible reference cycles:
logtail-js/packages/node/src/node.ts
Lines 104 to 112 in 174eee0
So, if I may share my opinion, I believe cycles coming from the context object should be cut off by not propagating them after sanitization operation.
I'm receiving an application-level critical error where the logging cannot parse the object I provide. With no information included in this error, I'm led to believe this is because I'm passing a cyclical object or a non-json to the log function.
Logtail has adequately functioned the last few months, so this is news to me and not something I do not know how to debug.
EDIT: my error also included msgpack
like @simonrozsival below. I did not capture that part of the stack trace:
Error: Not Acceptable at Node.sync [as _sync]
(/opt/render/project/src/packages/express/node_modules/@logtail/node/src/node.ts:43:13)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async handler (/opt/render/project/src/packages/express/node_modules/@logtail/tools/src/throttle.ts:36:23)
My Usage
const { Logtail } = require('@logtail/node');
const logtail: ILogger = new Logtail('REDACTED');
// where 'obj' is expected to be a JSON object or `Error` type. Fed directly from a `.catch` at times
logtail.error('message', obj);
Anytime there is a connection error to the Logtail URL (in.logtail.com), the library throws an error and this breaks code execution. I think errors like this should be silent or at least there should be an option to make them so.
When running logtail logger in a aws lambda function, there is no way to flush the logs before the function exists.
This causes some logs to either be lost or cause the fetch to logtail to fail and error.
Segment analytics for example provides a flush function to work in these scenarios. Please advise. Thanks!
The library logatail
failts two of my gh-action workflows:
@logtail/winston
:@logtail/nide
:On each of failed workflow runs, the failed step exits likeso:
Run actions/setup-node@v3
Attempting to download 19.x...
Not found in manifest. Falling back to download directly from Node
Acquiring 19.9.0 - x64 from https://nodejs.org/dist/v19.9.0/node-v19.9.0-linux-x64.tar.gz
aborted
Waiting 15 seconds before trying again
aborted
Waiting 19 seconds before trying again
Error: aborted
Hi,
just a question : your documentation talks about "query" API.
This api is used to get back logs entries from the cloud.
It's true that this is very simple to query logs but as we already have a Logtail "source" class, we may have a Logtail "query" class helper too. Or it's just I miss that?
Here is a simple sample of (1) use the lib to produce log (2) use axios lib to query logs.
If you decide to not introduce helper into this library, you may then maybe add this kind of sample in the documentation?
Best Regards
๐ค to the DEV team + Filip ;) ๐
// doc : https://docs.logtail.com/integrations/javascript
import { Logtail } from "@logtail/node";
import axios from "axios";
const action = {
produceLog: false,
queryLogs: true
}
function produceLog() {
const logtailSource = process.env.LOGTAIL_SOURCE;
// DEBUG // console.log(logtailSource);
const logtail = new Logtail(logtailSource);
logtail.info("Logtail installed " + new Date());
}
function queryLogs() {
const TEAM_TOKEN = process.env.LOGTAIL_TEAM_TOKEN;// pick from logtail team portal : https://logtail.com/team/0/teams/
const source_ids = process.env.LOGTAIL_SOURCE_IDS || null;// start without then pick source id from result
const LOGTAIL_BASE_API = 'https://logtail.com/api/v1';
const Authorization = `Bearer ${TEAM_TOKEN}`;
const axiosClient = axios.create({
baseURL: LOGTAIL_BASE_API,
timeout: 6000,//ms
headers: { Authorization }
});
const params = { source_ids }; // optional
axiosClient.get("/query", {params}).then(response => {
var responseText = `/query : status: ${response.status} ${response.statusText}`;
console.info({res: responseText, data: response.data.data});
}).catch(err => {
console.warn("error", err);
});
}
action.produceLog && produceLog();
action.queryLogs && queryLogs();
this is relatively straightforward to do in the browser; is this something that would be considered by the library, or that something we (as package users) would need to build on top ourselves?
Our server logs are completely useless during certain timeframes because of warnings like this. Can the logging library do a safe stringify which handles circular references? I don't know how our systems are including circular references, so for me to debug why this error is arising requires me to first see what the log is (which I cannot because of the circular references)
Feb 23 09:10:46 AM [Logtail] Found a circular reference when serializing logs. Please do not use circular references in your logs.
Feb 23 09:10:46 AM [Logtail] Found a circular reference when serializing logs. Please do not use circular references in your logs.
Feb 23 09:10:46 AM [Logtail] Found a circular reference when serializing logs. Please do not use circular references in your logs.
Feb 23 09:10:46 AM [Logtail] Found a circular reference when serializing logs. Please do not use circular references in your logs.
Feb 23 09:10:46 AM [Logtail] Found a circular reference when serializing logs. Please do not use circular references in your logs.
Feb 23 09:10:46 AM [Logtail] Found a circular reference when serializing logs. Please do not use circular references in your logs.
Feb 23 09:10:46 AM [Logtail] Found a circular reference when serializing logs. Please do not use circular references in your logs.
Feb 23 09:10:46 AM [Logtail] Found a circular reference when serializing logs. Please do not use circular references in your logs.
Feb 23 09:10:46 AM [Logtail] Found a circular reference when serializing logs. Please do not use circular references in your logs.
Feb 23 09:10:46 AM [Logtail] Found a circular reference when serializing logs. Please do not use circular references in your logs.
Feb 23 09:10:46 AM [Logtail] Found a circular reference when serializing logs. Please do not use circular references in your logs.
Feb 23 09:10:46 AM [Logtail] Found a circular reference when serializing logs. Please do not use circular references in your logs.
Here's an example of a safe way to decode these circular references: https://gist.github.com/zmmbreeze/9408172
Some logs do not appear unless additional logs come later. Seems as if there are some logs that are not synced until more come in. The _countLogged and _countSynced do seem to suggest this? It is also worth noting that this is running in a lambda function. The logger object shows:
_countLogged: 18,
_countSynced: 17,
_sourceToken: 'cGMBz7ikULX7EnL8mW7ADHEt',
_options: {
endpoint: 'https://in.logtail.com',
batchSize: 1000,
batchInterval: 1000,
syncMax: 10,
ignoreExceptions: true
},```
Hi,
I'm implementing logtail in a project and noticed it's being blocked.
I'm using Brave browser which blocks a lot by default. I've seen it block certain things purely based on names in files.
I think (assumption) it's blocking based on the word "log" in the url.
If anyone would like to add an exception this UBlock syntax works for me:
@@||in.logtail.com
many javascript environments are written using source code files that don't map 1:1 with the codebase used at runtime, due to typescript and/or minification
this makes viewing logs not such a great experience โ it would be awesome if betterstack supported JS sourcemaps, particularly for environments like cloudflare workers where all your code gets bundled up into a single giant JS file
Next.js, and Winston combination is not working as winston doesn't support async logging. As next.js server inside vercel runs as server less function we need async logging. And pino supports async logging. Please provide an official pino logtail transport plugin. Thanks!
Are you guys planning to add a support for flutter as well?
Writing typesafe procedures when dealing with the Context type feels very weird and I was wondering if it can be improved?
An example from my app:
// add runtime env information through a middleware
logtail.use(async (log) => {
if (log.context && (log.context as Context).runtime) {
const runtime = (log.context as Context).runtime as Context;
runtime.env = process.env.NODE_ENV;
const messagePrefix = process.env.NODE_ENV === "production" ? "" : "[DEV] ";
log.message = messagePrefix + log.message;
}
return {
...log,
};
});
A lot of as Context
's are needed to access the children in the context. Instead of this, being able to do this would be better:
// add runtime env information through a middleware
logtail.use(async (log) => {
if (log.context && log.context.runtime) {
log.context.runtime.env = process.env.NODE_ENV;
const messagePrefix = process.env.NODE_ENV === "production" ? "" : "[DEV] ";
log.message = messagePrefix + log.message;
}
return {
...log,
};
});
Is implementing this type possible?
I'm having a Forbidden error when I pause a source in BetterStack.
I tried to wrap my logtail.debug
calls into a try/catch
or followed them with a .catch
but it seems that the error is happening in the core of your lib.
By not being able to catch, it creates unnecessary noises in my logs files.
Do you have any idea how to catch the error ?
Here is the error btw
Error: Forbidden
at Node.sync [as _sync] (node_modules/@logtail/node/src/node.ts:37:13)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at handler (node_modules/@logtail/tools/src/throttle.ts:34:23)
As described in PR #36 the used in @logtail/node version restriction for Banyan is absolutely incorrect and points to the Beta version of the package.
Beta versions are not used by many.
Moreover, the @logtail/node works absolutely fine with lower versions of Bunyan, and this restriction causes issues with the dependency graph for users using the latest Bunyan (v. 1.8.15).
@trentm can elaborate on this probably more.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.