File tree Expand file tree Collapse file tree 2 files changed +20
-3
lines changed
Expand file tree Collapse file tree 2 files changed +20
-3
lines changed Original file line number Diff line number Diff line change 44 Context ,
55 ILogLevel ,
66 ILogtailLog ,
7- ILogtailOptions ,
7+ ILogtailEdgeOptions ,
88 LogLevel ,
99} from "@logtail/types" ;
1010import { Base } from "@logtail/core" ;
@@ -20,9 +20,17 @@ type Message = string | Error;
2020export class Edge extends Base {
2121 private _warnedAboutMissingCtx : Boolean = false ;
2222
23- public constructor ( sourceToken : string , options ?: Partial < ILogtailOptions > ) {
23+ private readonly warnAboutMissingExecutionContext : Boolean ;
24+
25+ public constructor (
26+ sourceToken : string ,
27+ options ?: Partial < ILogtailEdgeOptions > ,
28+ ) {
2429 super ( sourceToken , options ) ;
2530
31+ this . warnAboutMissingExecutionContext =
32+ options ?. warnAboutMissingExecutionContext ?? true ;
33+
2634 // Sync function
2735 const sync = async ( logs : ILogtailLog [ ] ) : Promise < ILogtailLog [ ] > => {
2836 const res = await fetch ( this . _options . endpoint , {
@@ -80,7 +88,10 @@ export class Edge extends Base {
8088
8189 if ( ctx ) {
8290 ctx . waitUntil ( log ) ;
83- } else if ( ! this . _warnedAboutMissingCtx ) {
91+ } else if (
92+ this . warnAboutMissingExecutionContext &&
93+ ! this . _warnedAboutMissingCtx
94+ ) {
8495 this . _warnedAboutMissingCtx = true ;
8596
8697 const warningMessage =
Original file line number Diff line number Diff line change @@ -80,6 +80,12 @@ export interface ILogtailOptions {
8080 **/
8181 sendLogsToBetterStack : boolean ;
8282}
83+ export interface ILogtailEdgeOptions extends ILogtailOptions {
84+ /**
85+ * Boolean to produce a warning when ExecutionContext hasn't been passed to the `log` method
86+ **/
87+ warnAboutMissingExecutionContext : boolean ;
88+ }
8389
8490export type ILogLevel = LogLevel | string ;
8591export enum LogLevel {
You can’t perform that action at this time.
0 commit comments