# Colours in logs

**URL:** <https://discourse.julialang.org/t/colours-in-logs/65181>\
**Category:** General Usage\
**Created:** [July 23, 2021, 1:49pm UTC](https://discourse.julialang.org/t/colours-in-logs/65181 "2021-07-23T13:49:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tlienart](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tlienart/32/7640_2.png) [@tlienart](https://discourse.julialang.org/u/tlienart)\
**Post date:** [July 23, 2021, 1:49pm UTC](https://discourse.julialang.org/t/colours-in-logs/65181/1 "2021-07-23T13:49:39Z")

</div>

Is there a way to colour part of a string in e.g. `@info`? similar to what Crayons or `printstyled` does.

I’d like to do something like:

```julia
information = "some info"
@info "A string with $(highlight(information))" 

```

thanks in advance

---

<div class="post-metadata">

**Author:** ![Skoffer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/skoffer/32/378_2.png) [@Skoffer](https://discourse.julialang.org/u/Skoffer)\
**Post date:** [July 23, 2021, 2:24pm UTC](https://discourse.julialang.org/t/colours-in-logs/65181/2 "2021-07-23T14:24:30Z")

</div>

You can use `printstyled`

```julia
function highlight(s, colour)
    io = IOBuffer()
    printstyled(IOContext(io, :color => true), s, color = colour)
    return io |> take! |> String
end

```

---

<div class="post-metadata">

**Author:** ![tlienart](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tlienart/32/7640_2.png) [@tlienart](https://discourse.julialang.org/u/tlienart)\
**Post date:** [July 23, 2021, 3:11pm UTC](https://discourse.julialang.org/t/colours-in-logs/65181/3 "2021-07-23T15:11:25Z")

</div>

wonderful, thank you
