> ## Documentation Index
> Fetch the complete documentation index at: https://docs.galileo.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# GalileoLogger

***

# Class: GalileoLogger

Defined in: [src/utils/galileo-logger.ts](https://github.com/rungalileo/galileo-js/blob/main/src/utils/galileo-logger.ts)

## Implements

* `IGalileoLogger`

## Constructors

### Constructor

```ts theme={null}
new GalileoLogger(config: GalileoLoggerConfig): GalileoLogger;
```

Defined in: [src/utils/galileo-logger.ts](https://github.com/rungalileo/galileo-js/blob/main/src/utils/galileo-logger.ts)

#### Parameters

##### config

`GalileoLoggerConfig` = `{}`

#### Returns

`GalileoLogger`

## Properties

### traces

```ts theme={null}
traces: Trace[] = [];
```

Defined in: [src/utils/galileo-logger.ts](https://github.com/rungalileo/galileo-js/blob/main/src/utils/galileo-logger.ts)

## Accessors

### terminated

#### Get Signature

```ts theme={null}
get terminated(): boolean;
```

Defined in: [src/utils/galileo-logger.ts](https://github.com/rungalileo/galileo-js/blob/main/src/utils/galileo-logger.ts)

Whether terminate() has completed on this logger. Once true, subsequent mutating calls no-op
with a warning and the logger has been deregistered from the singleton (if applicable).

##### Returns

`boolean`

#### Implementation of

```ts theme={null}
IGalileoLogger.terminated;
```

## Methods

### addAgentSpan()

```ts theme={null}
addAgentSpan(options: object): AgentSpan;
```

Defined in: [src/utils/galileo-logger.ts](https://github.com/rungalileo/galileo-js/blob/main/src/utils/galileo-logger.ts)

Add an agent span to the current parent. Agent spans can contain child spans (like workflow spans).

#### Parameters

##### options

Configuration for the agent span. Only `input` is required. This creates a parent span that can contain child spans.

###### agentType?

[`AgentType`](/sdk-api/typescript/reference/types/type-aliases/AgentType)

(Optional) The type of agent. One of: 'default', 'planner', 'react', 'reflection', 'router', 'classifier', 'supervisor', 'judge'. Defaults to 'default'.

###### createdAt?

`Date`

(Optional) The timestamp when the span was created.

###### durationNs?

`number`

(Optional) Duration of the span in nanoseconds.

###### input

`string`

The input content for the agent.

###### metadata?

`Record`\<`string`, `string`>

(Optional) Additional metadata as key-value pairs.

###### name?

`string`

(Optional) Name for the span (e.g., 'Planning Agent', 'Router Agent').

###### output?

`string`

(Optional) The output result from the agent.

###### redactedInput?

`string`

(Optional) Redacted version of the input.

###### redactedOutput?

`string`

(Optional) Redacted version of the output.

###### statusCode?

`number`

###### stepNumber?

`number`

(Optional) The step number in a multi-step process.

###### tags?

`string`\[]

(Optional) Array of tags to categorize the span.

#### Returns

[`AgentSpan`](/sdk-api/typescript/reference/types/classes/AgentSpan)

The created agent span.

#### Implementation of

```ts theme={null}
IGalileoLogger.addAgentSpan;
```

***

### addChildSpanToParent()

```ts theme={null}
addChildSpanToParent(span: Span): void;
```

Defined in: [src/utils/galileo-logger.ts](https://github.com/rungalileo/galileo-js/blob/main/src/utils/galileo-logger.ts)

Add a child span to the current parent (trace or workflow/agent span).
This method automatically propagates dataset information from the parent to the child span.

#### Parameters

##### span

[`Span`](/sdk-api/typescript/reference/types/type-aliases/Span)

The span to add as a child to the current parent.

#### Returns

`void`

#### Throws

Error if no trace or parent span exists.

#### Implementation of

```ts theme={null}
IGalileoLogger.addChildSpanToParent;
```

***

### addLlmSpan()

```ts theme={null}
addLlmSpan(options: object): LlmSpan;
```

Defined in: [src/utils/galileo-logger.ts](https://github.com/rungalileo/galileo-js/blob/main/src/utils/galileo-logger.ts)

Add a new LLM span to the current parent.

#### Parameters

##### options

Configuration for the LLM span. All parameters are optional except `input` and `output`.

###### createdAt?

`Date`

(Optional) The timestamp when the span was created. Defaults to current time if not provided.

###### durationNs?

`number`

(Optional) Duration of the span in nanoseconds.

###### events?

[`Event`](/sdk-api/typescript/reference/types/type-aliases/Event)\[]

(Optional) Array of events associated with the span.

###### input

[`LlmSpanAllowedInputType`](/sdk-api/typescript/reference/types/type-aliases/LlmSpanAllowedInputType)

The input content for the LLM span. Accepts string, Message, or arrays of these.

###### metadata?

`Record`\<`string`, `string`>

(Optional) Additional metadata as key-value pairs.

###### model?

`string`

(Optional) The name or identifier of the LLM model used (e.g., 'gpt-4o', 'claude-3-sonnet').

###### name?

`string`

(Optional) Name for the span.

###### numCachedInputTokens?

`number`

###### numInputTokens?

`number`

(Optional) Number of tokens in the input.

###### numOutputTokens?

`number`

(Optional) Number of tokens in the output.

###### numReasoningTokens?

`number`

###### output

[`LlmSpanAllowedOutputType`](/sdk-api/typescript/reference/types/type-aliases/LlmSpanAllowedOutputType)

The output content from the LLM span. Accepts string, Message, or arrays of these.

###### redactedInput?

[`LlmSpanAllowedInputType`](/sdk-api/typescript/reference/types/type-aliases/LlmSpanAllowedInputType)

(Optional) Redacted version of the input content.

###### redactedOutput?

[`LlmSpanAllowedOutputType`](/sdk-api/typescript/reference/types/type-aliases/LlmSpanAllowedOutputType)

(Optional) Redacted version of the output content.

###### statusCode?

`number`

(Optional) HTTP status code or execution status (e.g., 200 for success).

###### stepNumber?

`number`

(Optional) The step number in a multi-step process.

###### tags?

`string`\[]

(Optional) Array of tags to categorize the span.

###### temperature?

`number`

(Optional) The temperature parameter used for the LLM (typically 0.0-2.0).

###### timeToFirstTokenNs?

`number`

(Optional) Time to first token in nanoseconds (for streaming responses).

###### tools?

`JsonObject`\[]

(Optional) Array of tool definitions available to the LLM.

###### totalTokens?

`number`

(Optional) Total number of tokens used (input + output).

#### Returns

[`LlmSpan`](/sdk-api/typescript/reference/types/classes/LlmSpan)

The created LLM span, which is automatically added to the current parent.

#### Implementation of

```ts theme={null}
IGalileoLogger.addLlmSpan;
```

***

### addProtectSpan()

```ts theme={null}
addProtectSpan(options: object): ToolSpan;
```

Defined in: [src/utils/galileo-logger.ts](https://github.com/rungalileo/galileo-js/blob/main/src/utils/galileo-logger.ts)

Add a new Protect tool span to the current parent.
This is a specialized method for logging Galileo Protect tool spans.

#### Parameters

##### options

Configuration for the Protect span.

###### createdAt?

`Date`

(Optional) The timestamp when the span was created.

###### metadata?

`Record`\<`string`, `string`>

(Optional) Additional metadata as key-value pairs.

###### payload

`Payload`

Input to the Protect invoke method. Payload object with input and/or output attributes.

###### redactedPayload?

`Payload`

(Optional) Redacted version of the payload.

###### redactedResponse?

`ProtectResponse`

(Optional) Redacted version of the response.

###### response?

`ProtectResponse`

(Optional) Output from the Protect invoke method. Response object with text, traceMetadata, and status.

###### statusCode?

`number`

(Optional) HTTP status code or execution status (e.g., 200 for success).

###### stepNumber?

`number`

(Optional) The step number in a multi-step process.

###### tags?

`string`\[]

(Optional) Array of tags to categorize the span.

#### Returns

[`ToolSpan`](/sdk-api/typescript/reference/types/classes/ToolSpan)

The created Protect tool span.

#### Implementation of

```ts theme={null}
IGalileoLogger.addProtectSpan;
```

***

### addRetrieverSpan()

```ts theme={null}
addRetrieverSpan(options: object): RetrieverSpan;
```

Defined in: [src/utils/galileo-logger.ts](https://github.com/rungalileo/galileo-js/blob/main/src/utils/galileo-logger.ts)

Add a new retriever span to the current parent.

#### Parameters

##### options

Configuration for the retriever span. All parameters are optional except `input` and `output`.

###### createdAt?

`Date`

(Optional) The timestamp when the span was created.

###### durationNs?

`number`

(Optional) Duration of the span in nanoseconds.

###### input

`string`

The input query for the retriever.

###### metadata?

`Record`\<`string`, `string`>

(Optional) Additional metadata as key-value pairs.

###### name?

`string`

(Optional) Name for the span.

###### output

[`RetrieverSpanAllowedOutputType`](/sdk-api/typescript/reference/types/type-aliases/RetrieverSpanAllowedOutputType)

The output documents or results. Accepts string, Record\<string, string>, Document, or arrays of these. Document has properties: \{ content: string, metadata?: Record\<string, string | number | boolean> }.

###### redactedInput?

`string`

(Optional) Redacted version of the input query.

###### redactedOutput?

[`RetrieverSpanAllowedOutputType`](/sdk-api/typescript/reference/types/type-aliases/RetrieverSpanAllowedOutputType)

(Optional) Redacted version of the output.

###### statusCode?

`number`

(Optional) HTTP status code or execution status (e.g., 200 for success).

###### stepNumber?

`number`

(Optional) The step number in a multi-step process.

###### tags?

`string`\[]

(Optional) Array of tags to categorize the span.

#### Returns

[`RetrieverSpan`](/sdk-api/typescript/reference/types/classes/RetrieverSpan)

The created retriever span.

#### Implementation of

```ts theme={null}
IGalileoLogger.addRetrieverSpan;
```

***

### addSingleLlmSpanTrace()

```ts theme={null}
addSingleLlmSpanTrace(options: object): Trace;
```

Defined in: [src/utils/galileo-logger.ts](https://github.com/rungalileo/galileo-js/blob/main/src/utils/galileo-logger.ts)

Create a new trace with a single LLM span. This is a convenience method that combines trace creation
and LLM span creation in one call. The trace is automatically concluded, so no need to call conclude().

#### Parameters

##### options

Configuration for the single LLM span trace. All parameters are optional except `input` and `output`.

###### createdAt?

`Date`

(Optional) The timestamp when the span was created.

###### datasetInput?

`string`

(Optional) Input data for dataset evaluation.

###### datasetMetadata?

`Record`\<`string`, `string`>

(Optional) Metadata for dataset evaluation.

###### datasetOutput?

`string`

(Optional) Expected output for dataset evaluation.

###### durationNs?

`number`

(Optional) Duration of the span in nanoseconds.

###### events?

[`Event`](/sdk-api/typescript/reference/types/type-aliases/Event)\[]

(Optional) Array of events associated with the span.

###### input

[`LlmSpanAllowedInputType`](/sdk-api/typescript/reference/types/type-aliases/LlmSpanAllowedInputType)

The input content for the LLM span.

###### metadata?

`Record`\<`string`, `string`>

(Optional) Additional metadata as key-value pairs.

###### model?

`string`

(Optional) The name or identifier of the LLM model used (e.g., 'gpt-4o', 'claude-3-sonnet').

###### name?

`string`

(Optional) Name for the span.

###### numInputTokens?

`number`

(Optional) Number of tokens in the input.

###### numOutputTokens?

`number`

(Optional) Number of tokens in the output.

###### output

[`LlmSpanAllowedOutputType`](/sdk-api/typescript/reference/types/type-aliases/LlmSpanAllowedOutputType)

The output content from the LLM span.

###### redactedInput?

[`LlmSpanAllowedInputType`](/sdk-api/typescript/reference/types/type-aliases/LlmSpanAllowedInputType)

(Optional) Redacted version of the input content.

###### redactedOutput?

[`LlmSpanAllowedOutputType`](/sdk-api/typescript/reference/types/type-aliases/LlmSpanAllowedOutputType)

(Optional) Redacted version of the output content.

###### spanStepNumber?

`number`

(Optional) The step number for the span in a multi-step process.

###### statusCode?

`number`

(Optional) HTTP status code or execution status (e.g., 200 for success).

###### tags?

`string`\[]

(Optional) Array of tags to categorize the span.

###### temperature?

`number`

(Optional) The temperature parameter used for the LLM (typically 0.0-2.0).

###### timeToFirstTokenNs?

`number`

(Optional) Time to first token in nanoseconds (for streaming).

###### tools?

`JsonObject`\[]

(Optional) Array of tool definitions. Expected format: Array\<\{ type: 'function', function: \{ name: string, description?: string, parameters?: object } }>.

###### totalTokens?

`number`

(Optional) Total number of tokens used (input + output).

#### Returns

[`Trace`](/sdk-api/typescript/reference/types/classes/Trace)

The created trace containing the single LLM span.

#### Throws

Error if a trace or span is already in progress.

#### Implementation of

```ts theme={null}
IGalileoLogger.addSingleLlmSpanTrace;
```

***

### addSingleRetrieverSpanTrace()

```ts theme={null}
addSingleRetrieverSpanTrace(options: object): Trace;
```

Defined in: [src/utils/galileo-logger.ts](https://github.com/rungalileo/galileo-js/blob/main/src/utils/galileo-logger.ts)

Create a new trace with a single retriever span. This is a convenience method that combines trace creation
and retriever span creation in one call. The trace is automatically concluded, so no need to call conclude().

#### Parameters

##### options

Configuration for the single retriever span trace. All parameters are optional except `input` and `output`.

###### createdAt?

`Date`

(Optional) The timestamp when the span was created.

###### datasetInput?

`string`

(Optional) Input data for dataset evaluation.

###### datasetMetadata?

`Record`\<`string`, `string`>

(Optional) Metadata for dataset evaluation.

###### datasetOutput?

`string`

(Optional) Expected output for dataset evaluation.

###### durationNs?

`number`

(Optional) Duration of the span in nanoseconds.

###### input

`string`

The input query for the retriever span.

###### metadata?

`Record`\<`string`, `string`>

(Optional) Additional metadata as key-value pairs.

###### name?

`string`

(Optional) Name for the span.

###### output

[`RetrieverSpanAllowedOutputType`](/sdk-api/typescript/reference/types/type-aliases/RetrieverSpanAllowedOutputType)

The output documents or results from the retriever span.

###### redactedInput?

`string`

(Optional) Redacted version of the input query.

###### redactedOutput?

[`RetrieverSpanAllowedOutputType`](/sdk-api/typescript/reference/types/type-aliases/RetrieverSpanAllowedOutputType)

(Optional) Redacted version of the output.

###### spanStepNumber?

`number`

(Optional) The step number for the span in a multi-step process.

###### statusCode?

`number`

(Optional) HTTP status code or execution status (e.g., 200 for success).

###### tags?

`string`\[]

(Optional) Array of tags to categorize the span.

#### Returns

[`Trace`](/sdk-api/typescript/reference/types/classes/Trace)

The created trace containing the single retriever span.

#### Throws

Error if a trace or span is already in progress.

#### Implementation of

```ts theme={null}
IGalileoLogger.addSingleRetrieverSpanTrace;
```

***

### addSingleToolSpanTrace()

```ts theme={null}
addSingleToolSpanTrace(options: object): Trace;
```

Defined in: [src/utils/galileo-logger.ts](https://github.com/rungalileo/galileo-js/blob/main/src/utils/galileo-logger.ts)

Create a new trace with a single tool span. This is a convenience method that combines trace creation
and tool span creation in one call. The trace is automatically concluded, so no need to call conclude().

#### Parameters

##### options

Configuration for the single tool span trace. Only `input` is required.

###### createdAt?

`Date`

(Optional) The timestamp when the span was created.

###### datasetInput?

`string`

(Optional) Input data for dataset evaluation.

###### datasetMetadata?

`Record`\<`string`, `string`>

(Optional) Metadata for dataset evaluation.

###### datasetOutput?

`string`

(Optional) Expected output for dataset evaluation.

###### durationNs?

`number`

(Optional) Duration of the span in nanoseconds.

###### input

`string`

The input parameters for the tool span.

###### metadata?

`Record`\<`string`, `string`>

(Optional) Additional metadata as key-value pairs.

###### name?

`string`

(Optional) Name for the span (e.g., the tool name or function name).

###### output?

`string`

(Optional) The output result from the tool span.

###### redactedInput?

`string`

(Optional) Redacted version of the input.

###### redactedOutput?

`string`

(Optional) Redacted version of the output.

###### spanStepNumber?

`number`

(Optional) The step number for the span in a multi-step process.

###### statusCode?

`number`

(Optional) HTTP status code or execution status (e.g., 200 for success).

###### tags?

`string`\[]

(Optional) Array of tags to categorize the span.

###### toolCallId?

`string`

(Optional) Unique identifier for the tool call.

#### Returns

[`Trace`](/sdk-api/typescript/reference/types/classes/Trace)

The created trace containing the single tool span.

#### Throws

Error if a trace or span is already in progress.

#### Implementation of

```ts theme={null}
IGalileoLogger.addSingleToolSpanTrace;
```

***

### addSingleWorkflowSpanTrace()

```ts theme={null}
addSingleWorkflowSpanTrace(options: object): Trace;
```

Defined in: [src/utils/galileo-logger.ts](https://github.com/rungalileo/galileo-js/blob/main/src/utils/galileo-logger.ts)

Create a new trace with a single workflow span. This is a convenience method that combines trace creation
and workflow span creation in one call. The trace is automatically concluded, so no need to call conclude().

#### Parameters

##### options

Configuration for the single workflow span trace. Only `input` is required.

###### createdAt?

`Date`

(Optional) The timestamp when the span was created.

###### datasetInput?

`string`

(Optional) Input data for dataset evaluation.

###### datasetMetadata?

`Record`\<`string`, `string`>

(Optional) Metadata for dataset evaluation.

###### datasetOutput?

`string`

(Optional) Expected output for dataset evaluation.

###### durationNs?

`number`

(Optional) Duration of the span in nanoseconds.

###### input

`string`

The input content for the workflow span.

###### metadata?

`Record`\<`string`, `string`>

(Optional) Additional metadata as key-value pairs.

###### name?

`string`

(Optional) Name for the span.

###### output?

`string`

(Optional) The output result from the workflow span.

###### redactedInput?

`string`

(Optional) Redacted version of the input.

###### redactedOutput?

`string`

(Optional) Redacted version of the output.

###### spanStepNumber?

`number`

(Optional) The step number for the span in a multi-step process.

###### tags?

`string`\[]

(Optional) Array of tags to categorize the span.

#### Returns

[`Trace`](/sdk-api/typescript/reference/types/classes/Trace)

The created trace containing the single workflow span.

#### Throws

Error if a trace or span is already in progress.

#### Implementation of

```ts theme={null}
IGalileoLogger.addSingleWorkflowSpanTrace;
```

***

### addToolSpan()

```ts theme={null}
addToolSpan(options: object): ToolSpan;
```

Defined in: [src/utils/galileo-logger.ts](https://github.com/rungalileo/galileo-js/blob/main/src/utils/galileo-logger.ts)

Add a new tool span to the current parent.

#### Parameters

##### options

Configuration for the tool span. Only `input` is required.

###### createdAt?

`Date`

(Optional) The timestamp when the span was created.

###### durationNs?

`number`

(Optional) Duration of the span in nanoseconds.

###### input

`string`

The input parameters for the tool.

###### metadata?

`Record`\<`string`, `string`>

(Optional) Additional metadata as key-value pairs.

###### name?

`string`

(Optional) Name for the span (e.g., the tool name or function name).

###### output?

`string`

(Optional) The output result from the tool.

###### redactedInput?

`string`

(Optional) Redacted version of the input.

###### redactedOutput?

`string`

(Optional) Redacted version of the output.

###### statusCode?

`number`

(Optional) HTTP status code or execution status (e.g., 200 for success).

###### stepNumber?

`number`

(Optional) The step number in a multi-step process.

###### tags?

`string`\[]

(Optional) Array of tags to categorize the span.

###### toolCallId?

`string`

(Optional) Unique identifier for the tool call, typically from LLM tool\_calls (e.g., 'call\_abc123').

#### Returns

[`ToolSpan`](/sdk-api/typescript/reference/types/classes/ToolSpan)

The created tool span.

#### Implementation of

```ts theme={null}
IGalileoLogger.addToolSpan;
```

***

### addWorkflowSpan()

```ts theme={null}
addWorkflowSpan(options: object): WorkflowSpan;
```

Defined in: [src/utils/galileo-logger.ts](https://github.com/rungalileo/galileo-js/blob/main/src/utils/galileo-logger.ts)

Add a workflow span to the current parent. This is useful when you want to create a nested workflow span
within the trace or current workflow span. The next span you add will be a child of the current parent. To
move out of the nested workflow, use conclude().

#### Parameters

##### options

Configuration for the workflow span. Only `input` is required. This creates a parent span that can contain child spans.

###### createdAt?

`Date`

(Optional) The timestamp when the span was created.

###### durationNs?

`number`

(Optional) Duration of the span in nanoseconds.

###### input

`string`

The input content for the workflow.

###### metadata?

`Record`\<`string`, `string`>

(Optional) Additional metadata as key-value pairs.

###### name?

`string`

(Optional) Name for the span (e.g., 'Data Processing Workflow').

###### output?

`string`

(Optional) The output result from the workflow.

###### redactedInput?

`string`

(Optional) Redacted version of the input.

###### redactedOutput?

`string`

(Optional) Redacted version of the output.

###### statusCode?

`number`

(Optional) HTTP status code or execution status (e.g., 200 for success, 500 for error).

###### stepNumber?

`number`

(Optional) The step number in a multi-step process.

###### tags?

`string`\[]

(Optional) Array of tags to categorize the span.

#### Returns

[`WorkflowSpan`](/sdk-api/typescript/reference/types/classes/WorkflowSpan)

The created workflow span.

#### Implementation of

```ts theme={null}
IGalileoLogger.addWorkflowSpan;
```

***

### clearSession()

```ts theme={null}
clearSession(): void;
```

Defined in: [src/utils/galileo-logger.ts](https://github.com/rungalileo/galileo-js/blob/main/src/utils/galileo-logger.ts)

Clears the current session ID.

#### Returns

`void`

#### Implementation of

```ts theme={null}
IGalileoLogger.clearSession;
```

***

### conclude()

```ts theme={null}
conclude(options: object):
  | undefined
  | StepWithChildSpans;
```

Defined in: [src/utils/galileo-logger.ts](https://github.com/rungalileo/galileo-js/blob/main/src/utils/galileo-logger.ts)

Concludes the current trace or span, or all active traces/spans if concludeAll is true.

#### Parameters

##### options

Configuration for concluding.

###### concludeAll?

`boolean`

(Optional) Whether to conclude all active traces/spans. Defaults to false.

###### durationNs?

`number`

(Optional) Duration in nanoseconds.

###### output?

`string`

(Optional) The output content to set.

###### redactedOutput?

`string`

(Optional) The redacted output content to set.

###### statusCode?

`number`

(Optional) HTTP status code or execution status.

#### Returns

\| `undefined`
\| [`StepWithChildSpans`](/sdk-api/typescript/reference/types/classes/StepWithChildSpans)

The current parent after concluding, or undefined if all traces/spans were concluded.

#### Throws

Error if no trace or span exists to conclude.

#### Implementation of

```ts theme={null}
IGalileoLogger.conclude;
```

***

### continueTrace()

```ts theme={null}
continueTrace(traceId: string, parentId?: string): Promise<void>;
```

Defined in: [src/utils/galileo-logger.ts](https://github.com/rungalileo/galileo-js/blob/main/src/utils/galileo-logger.ts)

Continues an existing trace (and optionally a parent span) for distributed tracing.
Fetches the trace (and span if parentId is provided) from the API and sets them as current context.

#### Parameters

##### traceId

`string`

The ID of the trace to continue.

##### parentId?

`string`

(Optional) The ID of the parent span to continue under.

#### Returns

`Promise`\<`void`>

A promise that resolves when the trace (and optional span) context is set.

***

### currentParent()

```ts theme={null}
currentParent():
  | undefined
  | StepWithChildSpans;
```

Defined in: [src/utils/galileo-logger.ts](https://github.com/rungalileo/galileo-js/blob/main/src/utils/galileo-logger.ts)

Get the current parent from context or instance.

#### Returns

\| `undefined`
\| [`StepWithChildSpans`](/sdk-api/typescript/reference/types/classes/StepWithChildSpans)

The current parent span or trace, or undefined if none exists.

#### Implementation of

```ts theme={null}
IGalileoLogger.currentParent;
```

***

### currentSessionId()

```ts theme={null}
currentSessionId(): undefined | string;
```

Defined in: [src/utils/galileo-logger.ts](https://github.com/rungalileo/galileo-js/blob/main/src/utils/galileo-logger.ts)

Gets the current session ID.

#### Returns

`undefined` | `string`

The current session ID, or undefined if no session is active.

#### Implementation of

```ts theme={null}
IGalileoLogger.currentSessionId;
```

***

### flush()

```ts theme={null}
flush(): Promise<Trace[]>;
```

Defined in: [src/utils/galileo-logger.ts](https://github.com/rungalileo/galileo-js/blob/main/src/utils/galileo-logger.ts)

Flushes all traces to the server. Concludes any active traces before flushing.
When an ingestionHook is configured, traces are sent to the hook instead of the
API and client initialization is skipped (no API credentials required).

#### Returns

`Promise`\<[`Trace`](/sdk-api/typescript/reference/types/classes/Trace)\[]>

A promise that resolves to an array of flushed traces.

#### Implementation of

```ts theme={null}
IGalileoLogger.flush;
```

***

### hasActiveTrace()

```ts theme={null}
hasActiveTrace(): boolean;
```

Defined in: [src/utils/galileo-logger.ts](https://github.com/rungalileo/galileo-js/blob/main/src/utils/galileo-logger.ts)

Check if there is an active trace.

#### Returns

`boolean`

True if there is a current parent (trace or span), false otherwise.

#### Implementation of

```ts theme={null}
IGalileoLogger.hasActiveTrace;
```

***

### isLoggingDisabled()

```ts theme={null}
isLoggingDisabled(): boolean;
```

Defined in: [src/utils/galileo-logger.ts](https://github.com/rungalileo/galileo-js/blob/main/src/utils/galileo-logger.ts)

Checks if logging is disabled.

#### Returns

`boolean`

True if logging is disabled, false otherwise.

#### Implementation of

```ts theme={null}
IGalileoLogger.isLoggingDisabled;
```

***

### previousParent()

```ts theme={null}
previousParent():
  | undefined
  | StepWithChildSpans;
```

Defined in: [src/utils/galileo-logger.ts](https://github.com/rungalileo/galileo-js/blob/main/src/utils/galileo-logger.ts)

Get the previous parent (second-to-last item in the parent stack).

#### Returns

\| `undefined`
\| [`StepWithChildSpans`](/sdk-api/typescript/reference/types/classes/StepWithChildSpans)

The previous parent span or trace, or undefined if less than 2 items in the stack.

#### Implementation of

```ts theme={null}
IGalileoLogger.previousParent;
```

***

### pushParent()

```ts theme={null}
pushParent(span: StepWithChildSpans): void;
```

Defined in: [src/utils/galileo-logger.ts](https://github.com/rungalileo/galileo-js/blob/main/src/utils/galileo-logger.ts)

Push a span onto the parent stack so subsequent child spans nest under it.
Used by handlers that need to make leaf spans (like tool) act as parents.

#### Parameters

##### span

[`StepWithChildSpans`](/sdk-api/typescript/reference/types/classes/StepWithChildSpans)

#### Returns

`void`

#### Implementation of

```ts theme={null}
IGalileoLogger.pushParent;
```

***

### setSessionId()

```ts theme={null}
setSessionId(sessionId: string): void;
```

Defined in: [src/utils/galileo-logger.ts](https://github.com/rungalileo/galileo-js/blob/main/src/utils/galileo-logger.ts)

Sets the session ID for the logger.

#### Parameters

##### sessionId

`string`

The session ID to set.

#### Returns

`void`

#### Implementation of

```ts theme={null}
IGalileoLogger.setSessionId;
```

***

### startSession()

```ts theme={null}
startSession(options: StartSessionOptions): Promise<string>;
```

Defined in: [src/utils/galileo-logger.ts](https://github.com/rungalileo/galileo-js/blob/main/src/utils/galileo-logger.ts)

Starts a session in the active logger instance. If an externalId is provided, searches for an existing session with that external ID and reuses it if found.

Note: When an existing session is found via externalId, it is returned as-is. All other options
(name, previousSessionId, metadata) are ignored - they only apply when creating a new session.
To update an existing session, use an explicit update method.

#### Parameters

##### options

[`StartSessionOptions`](/sdk-api/typescript/reference/README/interfaces/StartSessionOptions) = `{}`

Configuration for the session.

#### Returns

`Promise`\<`string`>

A promise that resolves to the ID of the session (either newly created or existing).

#### Implementation of

```ts theme={null}
IGalileoLogger.startSession;
```

***

### startTrace()

```ts theme={null}
startTrace(options: object): Trace;
```

Defined in: [src/utils/galileo-logger.ts](https://github.com/rungalileo/galileo-js/blob/main/src/utils/galileo-logger.ts)

Starts a new trace.

#### Parameters

##### options

Configuration for the trace.

###### createdAt?

`Date`

(Optional) The timestamp when the trace was created.

###### datasetInput?

`string`

(Optional) Input data for dataset evaluation.

###### datasetMetadata?

`Record`\<`string`, `string`>

(Optional) Metadata for dataset evaluation.

###### datasetOutput?

`string`

(Optional) Expected output for dataset evaluation.

###### durationNs?

`number`

(Optional) Duration of the trace in nanoseconds.

###### externalId?

`string`

(Optional) External identifier for the trace.

###### input

`string`

The input content for the trace.

###### metadata?

`Record`\<`string`, `string`>

(Optional) Additional metadata as key-value pairs.

###### name?

`string`

(Optional) Name for the trace.

###### output?

`string`

(Optional) The output content for the trace.

###### redactedInput?

`string`

(Optional) Redacted version of the input.

###### redactedOutput?

`string`

(Optional) Redacted version of the output.

###### tags?

`string`\[]

(Optional) Array of tags to categorize the trace.

#### Returns

[`Trace`](/sdk-api/typescript/reference/types/classes/Trace)

The created trace.

#### Throws

Error if a trace is already in progress.

#### Implementation of

```ts theme={null}
IGalileoLogger.startTrace;
```

***

### terminate()

```ts theme={null}
terminate(): Promise<void>;
```

Defined in: [src/utils/galileo-logger.ts](https://github.com/rungalileo/galileo-js/blob/main/src/utils/galileo-logger.ts)

Terminates the logger. In batch mode, flushes all traces. In streaming mode, waits for all tasks to complete.
After termination, subsequent mutating calls no-op with a warning, and loggers created through the
singleton are removed from the singleton's registry. Calling terminate() again is a no-op.

#### Returns

`Promise`\<`void`>

A promise that resolves when termination is complete.

#### Implementation of

```ts theme={null}
IGalileoLogger.terminate;
```

***

### ~~create()~~

```ts theme={null}
static create(config: GalileoLoggerConfigExtended): Promise<GalileoLogger>;
```

Defined in: [src/utils/galileo-logger.ts](https://github.com/rungalileo/galileo-js/blob/main/src/utils/galileo-logger.ts)

**`Internal`**

Static factory method to create and initialize a logger.
Use this instead of `new GalileoLogger()` when traceId or spanId are provided.

#### Parameters

##### config

`GalileoLoggerConfigExtended` = `{}`

Logger configuration

#### Returns

`Promise`\<`GalileoLogger`>

Promise that resolves to a fully initialized logger

#### Throws

Error if config validation fails or trace/span initialization fails

#### Deprecated

Use `new GalileoLogger(config)` directly. For streaming traceId/spanId initialization, call `initTrace`/`initSpan` afterward. Will be made internal in a future release.

***

### getLastOutput()

```ts theme={null}
static getLastOutput(node?: BaseSpan):
  | undefined
  | {
  output?: string;
  redactedOutput?: string;
};
```

Defined in: [src/utils/galileo-logger.ts](https://github.com/rungalileo/galileo-js/blob/main/src/utils/galileo-logger.ts)

Gets the last output from a span or its children recursively.

#### Parameters

##### node?

[`BaseSpan`](/sdk-api/typescript/reference/types/classes/BaseSpan)

(Optional) The span node to get output from.

#### Returns

\| `undefined`
\| \{
`output?`: `string`;
`redactedOutput?`: `string`;
}

The output and redacted output, or undefined if not found.
