# Getting started

Requirements:

* Dart 3.0.0 or greater (check out [dart-overlay.nix](https://github.com/roman-vanesyan/dart-overlay.nix) if you use Nix)

### Installation

To start using `strlog` add the package via `pub`

```shell-session
dart pub add strlog
```

### Hello world

The simplest way to get started with the strlog is by using a global logger

```dart
import 'package:strlog/global_logger.dart' as log;
import 'package:strlog/strlog.dart';

void main() {
    log.info('Greeting', const [Str('who', 'world'), Str('what', 'hello')]);
}
```

```log
2024-10-14 22:11:16.927220 [INFO]: Hello world who=world what=hello
```

### Set up the logger

```dart
import 'dart:io';

import 'package:strlog/strlog.dart';
import 'package:strlog/handlers.dart';
import 'package:strlog/formatters.dart';

final _defaultFormatter = TextFormatter.withDefaults();

void main() {
    final logger = Logger.detached()..handler = ConsoleHandler(formatter: _defaultFormatter); 

    logger.info('A new log with bound PID appears on a screen', [Int('pid', pid)]);
}
```

Check out [reference documentation](https://pub.dev/documentation/strlog) for a detailed overview of the API.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://strlog.inout.gg/readme/getting-started.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
