> Agent-readable docs index: /llms.txt. Download /docs.zip to grep all markdown files locally.

---
title: Logging
icon: terminal
---

# <ApiPageIcon icon="terminal" />Logging

## log<ApiTag label="global table" />

Writes text to the game console and to the event log on the screen.

Every function here converts its arguments to strings and joins them without a separator,
in the same way as `print`.

<ApiMembers>
  <ApiMember kind="fn" name="log.Print" summary="The same function as `print`. Writes a line to the game console with the `neverlose ·` prefix." args="...?" sig="[{&#x22;s&#x22;:&#x22;log.Print&#x22;},{&#x22;s&#x22;:&#x22;(&#x22;},{&#x22;s&#x22;:&#x22;[&#x22;},{&#x22;s&#x22;:&#x22;...&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;any&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;},{&#x22;s&#x22;:&#x22;]&#x22;},{&#x22;s&#x22;:&#x22;)&#x22;}]" params="[{&#x22;n&#x22;:&#x22;...&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;any&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;}],&#x22;d&#x22;:&#x22;Values to print.&#x22;,&#x22;o&#x22;:true}]">
    <ApiNotes>
      When the Lua Output option of Log Events is enabled in the menu, the line is also added to
      the event log on the screen.
    </ApiNotes>
  </ApiMember>

  <ApiMember kind="fn" name="log.Console" summary="Writes one line to the game console exactly as given, without the `neverlose ·` prefix. The line is always written to the console, whatever the Lua Output setting is. If the text is empty, nothing is written." args="...?" sig="[{&#x22;s&#x22;:&#x22;log.Console&#x22;},{&#x22;s&#x22;:&#x22;(&#x22;},{&#x22;s&#x22;:&#x22;[&#x22;},{&#x22;s&#x22;:&#x22;...&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;any&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;},{&#x22;s&#x22;:&#x22;]&#x22;},{&#x22;s&#x22;:&#x22;)&#x22;}]" params="[{&#x22;n&#x22;:&#x22;...&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;any&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;}],&#x22;d&#x22;:&#x22;Values to write.&#x22;,&#x22;o&#x22;:true}]">
    <ApiNotes>
      Colour codes change the colour of the text that comes after them. Use `\aRRGGBBAA` with eight
      hex digits for a custom colour. The alpha digits are ignored, so the text is always fully
      visible. Use `\aDEFAULT` for the default console colour and `\aACCENT` for the menu accent
      colour.
    </ApiNotes>

    <ApiExample title="Colored console line">
      ```lua luaintelligence=true semantic="lua:cs2:cs2/api_reference/runtime/log:0:4ce450f79019"
      log.Console("\a7FDBFFFFmy script\aDEFAULT loaded")
      ```
    </ApiExample>
  </ApiMember>

  <ApiMember kind="fn" name="log.Event" summary="Adds an entry to the event log on the screen. Entries are shown only while the Event Logs window is enabled in the menu. This function does not write to the game console. Use `log.Console` to write to the console. If the text is empty, no entry is added." args="icon?, color?, ...?" sig="[{&#x22;s&#x22;:&#x22;log.Event&#x22;},{&#x22;s&#x22;:&#x22;(&#x22;},{&#x22;s&#x22;:&#x22;[&#x22;},{&#x22;s&#x22;:&#x22;icon&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;string&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#string&#x22;},{&#x22;s&#x22;:&#x22;, &#x22;},{&#x22;s&#x22;:&#x22;color&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;Color&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/mathlib/color#color-1&#x22;},{&#x22;s&#x22;:&#x22;, &#x22;},{&#x22;s&#x22;:&#x22;...&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;any&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;},{&#x22;s&#x22;:&#x22;]&#x22;},{&#x22;s&#x22;:&#x22;)&#x22;}]" params="[{&#x22;n&#x22;:&#x22;icon&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;string&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#string&#x22;}],&#x22;d&#x22;:&#x22;The name of a Font Awesome icon, such as `\&#x22;bell\&#x22;`. If the name is not a known icon name, the string is drawn as it is, so you can also pass an icon character. Pass `\&#x22;\&#x22;` to show no icon. Pass `nil` to use the default file icon.&#x22;,&#x22;o&#x22;:true},{&#x22;n&#x22;:&#x22;color&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;Color&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/mathlib/color#color-1&#x22;}],&#x22;d&#x22;:&#x22;The colour of the bar on the side of the entry, the icon, and the bold text. Pass `nil` to use the default blue colour, `Color(79, 125, 255)`.&#x22;,&#x22;o&#x22;:true},{&#x22;n&#x22;:&#x22;...&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;any&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;}],&#x22;d&#x22;:&#x22;The text of the entry.&#x22;,&#x22;o&#x22;:true}]">
    <ApiNotes>
      If the text is the same as the text of the last entry, the last entry stays on the screen
      for longer and a counter such as `[x2]` is added to it.

      Put `^` before and after the text that you want to be bold. Bold text is drawn in the colour
      given by `color`. Use `\n` to start a new line.
    </ApiNotes>

    <ApiExample title="Bold text in an event">
      ```lua luaintelligence=true semantic="lua:cs2:cs2/api_reference/runtime/log:1:2ee2a095e30b"
      log.Event("bell", Color(120, 200, 255), "Loaded ^", cloud.GetScript().name, "^")
      ```
    </ApiExample>
  </ApiMember>
</ApiMembers>
