Forum Discussion

Holly_Greger's avatar
Holly_Greger
Contributor
14 years ago

Changing log output line text color

Is there any way to change the color of the text written to the log output using groovy? I know when an exception is thrown it appears in red in the error log. Could I do this programmatically to the Log Output?

5 Replies

  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi Holly,

    sorry, this isn't currently possible.. please add a feature request to the corresponding Board here detailing your requirements and it will be in our backlog

    regards!

    /Ole
    eviware.com
    • OV's avatar
      OV
      Frequent Contributor



      // Edit log messages
      function CorrectRGBComponent(component)
      {
      component = aqConvert.VarToInt(component);
      if (component < 0)
      component = 0;
      else
      if (component > 255)
      component = 255;
      return component;
      }

      function RGB(r, g, b)
      {
      r = CorrectRGBComponent(r);
      g = CorrectRGBComponent(g);
      b = CorrectRGBComponent(b);
      return r | (g << 8) | (b << 16);
      }

      function Pass(Msg)

      {
      var Attr;
      Attr = Log.CreateNewAttributes();
      Attr.FontColor = RGB(22, 20, 23);
      Attr.BackColor = RGB(170, 227, 162);

      // Passes the LogAttributes object to the Message function
      Log.Message("PASS - " + Msg, "", pmNormal, Attr);
      }

      // Update the log file with the FAIL info and clore it red
      function Fail(Msg)

      {
      var Attr;
      Attr = Log.CreateNewAttributes();
      Attr.FontColor = RGB(251, 251, 251);
      Attr.BackColor = RGB(221, 33, 60);

      // Passes the LogAttributes object to the Message function
      Log.Error("FAIL - " + Msg, "", pmNormal, Attr);
      }


      function Information(Msg)
      {
      var Attr;
      Attr = Log.CreateNewAttributes();
      Attr.FontColor = RGB(22, 20, 23);
      Attr.BackColor = RGB(197, 197, 198);

      // Passes the LogAttributes object to the Message function
      Log.Message("INFORMATION - " + Msg, "", pmNormal, Attr);
      }

      • PramodYadav's avatar
        PramodYadav
        Contributor

        Looks awesome. Can you give an example on how to use this? I tried running the code but get multiple compilation errors.