Skip to content

Commit

Permalink
doc: add the logging guide
Browse files Browse the repository at this point in the history
  • Loading branch information
homuler committed Feb 17, 2025
1 parent 29a1be9 commit e6ad333
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
36 changes: 36 additions & 0 deletions docs/Logging.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Logging

To debug the application, it is useful to enable logging.

By default, the plugin outputs INFO level logs.\
You can change the log level at runtime as follows:

```cs
Mediapipe.Unity.Logger.MinLogLevel = Logger.LogLevel.Debug;
```

Additionally, MediaPipe uses [Google Logging Library(glog)](https://github.com/google/glog) internally.\
You can configure it by [setting flags](https://github.com/google/glog#setting-flags).

```cs
Glog.Logtostderr = true; // when true, log will be output to `Editor.log` / `Player.log`
Glog.Minloglevel = 0; // output INFO logs
Glog.V = 3; // output more verbose logs
```

To enable those flags, call `Glog.Initialize` when the application starts.

```cs
Glog.Initialize("MediaPipeUnityPlugin");
```

> :skull_and_crossbones: `Glog.Initialize` can be called only once. The second call will crash your application or UnityEditor.
> :bulb: If you look closely at `Editor.log`, you will notice the following warning log output.\
>
> ```txt
> WARNING: Logging before InitGoogleLogging() is written to STDERR
> ```
>
> To suppress it, you need to call `Glog.Initialize`.\
> However, without setting `true` to `Glog.Logtostderr`, glog won't output to `Editor.log` / `Player.log`.
14 changes: 14 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Contents

- [Build](Build.md)
- [Logging](Logging.md)

## Tutorials

- [Tutorial - Task API](Tutorial-Task-API.md)
- [Tutorial - Hello World!](Tutorial-Hello-World.md)
- [Tutorial - Custom Graph](Tutorial-Custom-Graph.md)

## API Reference

:construction: Under construction

0 comments on commit e6ad333

Please sign in to comment.