# Log

You still can call `Debug.Log()` or `print()`

Also you can use `TIM.Console.Log()`

Here is an example:

```
TIM.Console.Log("Game started");
```

<figure><img src="https://2580249083-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtMR8cCnFq2WqljWgSgJA%2Fuploads%2FZsJegrsN5SXDsUfQlSVl%2Fimage.png?alt=media&#x26;token=1be8f687-2b59-4c86-a2e0-6d2c82af984c" alt=""><figcaption><p>How it looks like in Console</p></figcaption></figure>

Also you can change the MessageType of your message:

{% hint style="info" %}
Message types:&#x20;

💬 Default

🟨 Warning

🟥 Error

🟦 Network
{% endhint %}

```
TIM.Console.Log("Server started", MessageType.Network);
```

<figure><img src="https://2580249083-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtMR8cCnFq2WqljWgSgJA%2Fuploads%2FmuiUIcbTnq73qUGHlFug%2Fimage.png?alt=media&#x26;token=963da143-5cc1-4871-84e0-d8f01614c2a2" alt=""><figcaption><p>How it looks like in Console</p></figcaption></figure>

## Logchain

{% hint style="info" %}
Sometimes an in-game event does not happen immediately, it can be divided into several stages. 'Logchain' was created for this purpose
{% endhint %}

### Example

You are downloading an image from Internet in 3 stages:

1. Web request
2. Downloading
3. Converting downloaded data to Texture2D

You can group all these messages into one Logchain. Just give it name.&#x20;

For example: "Image downloading". Here is how you can print a message:

```
Console.Log("Your log", MessageType.Default, "Image downloading");
```

So how our method can look like:

```
IEnumerator DownloadImage(string imageUrl)
    {
        WWW www = new WWW(imageUrl);
        string logchain = "Image downloading";

        Console.Log("Web request sent", MessageType.Network, logchain);
        yield return www;
        
        if (www.error != null)
        {
            Console.Log(www.error, MessageType.Error, logchain);
        }
        else
        {
            Console.Log("data has been downloaded", MessageType.Network, logchain);
            Texture2D texture = www.texture;
            
            if (texture == null)
            {
                Console.Log("Data doesn't contant a texture!", MessageType.Error, logchain);
            }
            else
            {
                Console.Log("Success!", MessageType.Default, logchain);
            }
        }
    }
```

Lets try it!

Execute our coroutine by StartCoroutine() method. And paste image URL as argument.

```
private void Start()
{
    // I found random image from internet and copied the URL:
    StartCoroutine(DownloadImage("https://www.sunhome.ru/i/wallpapers/221/frukti-oboi.orig.jpg"));
}
```

Open console by \` and you can see that messages are displayed in Console window and in Logchain window as well

<figure><img src="https://2580249083-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtMR8cCnFq2WqljWgSgJA%2Fuploads%2FVgaPsvAeeDmYOZrVKFk8%2Fimage.png?alt=media&#x26;token=7f4cba31-b38c-4156-854f-44b7ad5f2dac" alt=""><figcaption><p>How it looks like in console</p></figcaption></figure>

## Hidden messages

{% hint style="info" %}
Hidden messages are hidden in Console (but not hidden in Logchain window)
{% endhint %}

Lets take our last example with downloading image. If we will download images many times we will have many messages in Console. But we can organize it better! We can hide logs in Console but keep them visible in Logchain window. You just need to set last argument `hidden` of `TIM.Console.Log()` function to true:

```
Console.Log("Web request sent", MessageType.Network, "Logchain name", true);
```

And how our function looks like now:

```
IEnumerator DownloadImage(string imageUrl)
    {
        WWW www = new WWW(imageUrl);
        string logchain = "Image downloading";

        Console.Log("Web request sent", MessageType.Network, logchain, true);
        yield return www;
        
        if (www.error != null)
        {
            Console.Log(www.error, MessageType.Error, logchain); // we don't want to hide errors
        }
        else
        {
            Console.Log("data has been downloaded", MessageType.Network, logchain, true);
            Texture2D texture = www.texture;
            
            if (texture == null)
            {
                Console.Log("Data doesn't contant a texture!", MessageType.Error, logchain); // we don't want to hide errors
            }
            else
            {
                Console.Log("Success!", MessageType.Default, logchain, true);
            }
        }
    }
```

What we will see in Console:

<figure><img src="https://2580249083-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtMR8cCnFq2WqljWgSgJA%2Fuploads%2F8EKZ4p2XB1DzPDlHK1hI%2Fimage.png?alt=media&#x26;token=1cafc6d0-d452-441b-a0d4-1773c9ff36f3" alt=""><figcaption><p>Console is clear. But Logchain exists.</p></figcaption></figure>

You can enable visibility of hidden messages by clicking this button:

<figure><img src="https://2580249083-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtMR8cCnFq2WqljWgSgJA%2Fuploads%2FCPTXfzTeDPSOpukZ0ydF%2Fimage.png?alt=media&#x26;token=4f3f7ae4-2196-4a0b-b732-316cd4c93bba" alt=""><figcaption></figcaption></figure>

Toggle it and what you can see now:

<figure><img src="https://2580249083-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtMR8cCnFq2WqljWgSgJA%2Fuploads%2FzS3O6KsHiV8GwULhB9j4%2Fimage.png?alt=media&#x26;token=bba8ca7b-38a6-4587-883a-e54cb1f29f73" alt=""><figcaption></figcaption></figure>
