> ## 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.

# singleton

## GalileoLoggerSingleton

A singleton class that manages a collection of GalileoLogger instances.

This class ensures that only one instance exists across the application and
provides a thread-safe way to retrieve or create GalileoLogger clients based on
the given 'project' and 'log\_stream' parameters. If the parameters are not provided,
the class attempts to read the values from the environment variables
GALILEO\_PROJECT and GALILEO\_LOG\_STREAM. The loggers are stored in a dictionary
using a tuple (project, log\_stream) as the key.

### flush

```python theme={null}
def flush(self,
          project: Optional[str]=None,
          log_stream: Optional[str]=None,
          experiment_id: Optional[str]=None,
          mode: Optional[str]=None) -> None
```

Flush (upload and clear) a GalileoLogger instance.

If both project and log\_stream are None, then all cached loggers are flushed
and cleared. Otherwise, only the specific logger corresponding to the provided
key (project, log\_stream) is flushed and removed.

**Arguments**

* `project (Optional[str], optional)`: The project name. Defaults to None.
* `log_stream (Optional[str], optional)`: The log stream name. Defaults to None.
* `experiment_id (Optional[str], optional)`: The experiment ID. Defaults to None.
* `mode (Optional[str], optional)`: The logger mode. Defaults to GALILEO\_MODE env var, or "batch" if not set.

### flush\_all

```python theme={null}
def flush_all(self) -> None
```

Flush (upload and clear) all GalileoLogger instances.

### get

```python theme={null}
def get(self,
        *,
        project: Optional[str]=None,
        log_stream: Optional[str]=None,
        experiment_id: Optional[str]=None,
        mode: Optional[str]=None,
        local_metrics: Optional[list[LocalMetricConfig]]=None,
        trace_id: Optional[str]=None,
        span_id: Optional[str]=None,
        ingestion_hook: Optional[Callable]=None) -> GalileoLogger
```

Retrieve an existing GalileoLogger or create a new one if it does not exist.

This method first computes the key from the project and log\_stream parameters,
checks if a logger exists in the cache, and if not, creates a new GalileoLogger.
The creation and caching are done in a thread-safe manner.

**Arguments**

* `project (Optional[str], optional)`: The project name. Defaults to None.
* `log_stream (Optional[str], optional)`: The log stream name. Defaults to None.
* `experiment_id (Optional[str], optional)`: The experiment ID. Defaults to None.
* `local_metrics (Optional[list[LocalScorerConfig]], optional)`: Local scorers to run on traces/spans.
  Only used if initializing a new logger, ignored otherwise.  Defaults to None.

**Returns**

* `GalileoLogger`: An instance of GalileoLogger corresponding to the key.

### get\_all\_loggers

```python theme={null}
def get_all_loggers(self) -> dict[tuple[str, ...], GalileoLogger]
```

Retrieve a copy of the dictionary containing all active loggers.

**Returns**

* A dictionary mapping keys to their corresponding GalileoLogger instances.

### reset

```python theme={null}
def reset(self,
          project: Optional[str]=None,
          log_stream: Optional[str]=None,
          experiment_id: Optional[str]=None,
          mode: Optional[str]=None) -> None
```

Reset (terminate and remove) one or all GalileoLogger instances.

**Arguments**

* `project (Optional[str], optional)`: The project name. Defaults to None.
* `log_stream (Optional[str], optional)`: The log stream name. Defaults to None.
* `experiment_id (Optional[str], optional)`: The experiment ID. Defaults to None.
* `mode (Optional[str], optional)`: The logger mode. Defaults to GALILEO\_MODE env var, or "batch" if not set.

### reset\_all

```python theme={null}
def reset_all(self) -> None
```

Reset (terminate and remove) all GalileoLogger instances.
