[Guide] Pretty logs on the forum

Post logs, pictures, poetry and more. (Please request the permission of others before posting logs about their characters. Thank you!)

Moderators: Maeve, Maeve

Post Reply
User avatar
Taunya
Posts: 561
Joined: Mon Aug 08, 2016 3:08 am

Wed May 16, 2018 12:04 am

We've got a new LOG bbcode on the forums now, which makes displaying logs in forum posts a bit prettier!

Like CODE, it'll keep things aligned correctly with monospaced characters and preserve whitespace, so you can include ASCII art.
Unlike CODE, LOG won't put things in a box with green text, and BBcodes will work inside of it, allowing the use of colors!

CODE:

Code: Select all

          Based on DikuMUD by Hans Staerfeldt, Katja Nyboe,
          Tom Madsen, Michael Seifert, and Sebastian Hammer
          Based on MERC 2.1 code by Hatchet, Furey and Kahn
          Based on ROM 2.4 copyright 1993-1998 Russ Taylor

                                                       
                             _ (\                       /) _
                            //\_\\/\                 /\//_/\\
                           ((   `>\_)               (_/<`   ))
                            \\./` \\,      _._      ,// `\.//
The Inquisition MUTT         \/    \|\.---`   `---./|/    \/
2010-Present Kinaed                 |     _____     |
2004-2008 by Ephera                  \   ]==o==[   /
inq 2.5 by Tamara Boileau            |    \_ _/    |
                                     |      V      |
   -_  ---___- ,,                    \     .V.     /
      (' ||    ||                     \   <___>   /
     ((  ||    ||/\\  _-_              \         /
    ((   ||    || || || \\              `.     .'
     (( //     || || ||/                //`:::`\\
       -____-  \\ |/ \\,/              //   '   \\
                                      //         \\
                                     (/           \)

 _-_,                                ,                
   //                    '        '  ||   '          
  || \\/\\  /'\\ \\ \\ \\  _-_, \\ =||= \\  /'\\ \\/\\
 -|| || || || || || || || ||_.  ||  ||  || || || || ||
  || || || || || || || ||  - || ||  ||  || || || || ||
_-_, \\ \\ \\,|| \\/\\ \\ ,-_-  \\  \\, \\ \\,/  \\ \\
              ||
              |/                          L E G A C Y

By what name shall history remember ye? [Type your desired character name.]
LOG:
          Based on DikuMUD by Hans Staerfeldt, Katja Nyboe,
          Tom Madsen, Michael Seifert, and Sebastian Hammer
          Based on MERC 2.1 code by Hatchet, Furey and Kahn
          Based on ROM 2.4 copyright 1993-1998 Russ Taylor

                                                       
                             _ (\                       /) _
                            //\_\\/\                 /\//_/\\
                           ((   `>\_)               (_/<`   ))
                            \\./` \\,      _._      ,// `\.//
The Inquisition MUTT         \/    \|\.---`   `---./|/    \/
2010-Present Kinaed                 |     _____     |
2004-2008 by Ephera                  \   ]==o==[   /
inq 2.5 by Tamara Boileau            |    \_ _/    |
                                     |      V      |
   -_  ---___- ,,                    \     .V.     /
      (' ||    ||                     \   <___>   /
     ((  ||    ||/\\  _-_              \         /
    ((   ||    || || || \\              `.     .'
     (( //     || || ||/                //`:::`\\
       -____-  \\ |/ \\,/              //   '   \\
                                      //         \\
                                     (/           \)

 _-_,                                ,                
   //                    '        '  ||   '          
  || \\/\\  /'\\ \\ \\ \\  _-_, \\ =||= \\  /'\\ \\/\\
 -|| || || || || || || || ||_.  ||  ||  || || || || ||
  || || || || || || || ||  - || ||  ||  || || || || ||
_-_, \\ \\ \\,|| \\/\\ \\ ,-_-  \\  \\, \\ \\,/  \\ \\
              ||
              |/                          L E G A C Y

By what name shall history remember ye? [Type your desired character name.]

So! How to make pretty logs like this for the forums?
If your client can save raw log files, there's a handy converter called Ansifilter, which can convert raw ANSI codes like muds use to bbcode!

So first, you'll likely want to use a color map with it. Here's mine, but you can adjust the colors to how you like them:

Code: Select all

0 = #666666 -- black
1 = #990000 -- red
2 = #00A600 -- green
3 = #D9A000 -- yellow
4 = #00006F -- blue
5 = #B200B2 -- magenta
6 = #00A6B2 -- cyan
7 = #BFBFBF -- white
8 = #666666 -- grey
9 = #E50000 -- bright red
10 = #00D900 -- bright green
11 = #E5E500 -- bright yellow
12 = #0000FF -- bright blue
13 = #E500E5 -- bright magenta
14 = #00E5E5 -- bright cyan
15 = #FFFFFF -- bright white
Save that as colormap.txt, and you can load it with ansifilter.

For Mac users, here's a script I wrote that allows you to copy a part of the raw log, and it'll convert it and clean it up for immediate pasting into the forums.
Some of its features:
  • It deletes all plain white color codes. the LOG bbcode sets the default to white, so they're not needed, and removing them considerably cuts down the characters needed.
    It also erases color codes that don't actually color anything.
    it filters out OOC and visnet channels, as well as Merchants and Physicians (others can be added)
    It filters out things I tend to spam a lot, like score, the rumor list, who list, where list, and others.
It requires BBEdit (the free version should work), and the command-line ansifilter installed using homebrew (brew install ansifilter). The color codes in the filters will need to be changed if you don't use the colormap above.
To use, paste the following into Script Editor (Found in the Utilities folder), set the colormap variable to the path to your colormap file, open up BBEdit, copy the part of the raw log you'd like to use, then click the "Run" button (▶️) in Script Editor. The log should then be ready to be pasted to the forums inside a LOG bbcode.

Code: Select all

set colormap to "/path/to/colormap.txt" -- change this to the path to your colormap.txt file.

tell application "BBEdit"
	set the clipboard to (replace "^\\r(.+)" using "\\1" searchingString (the clipboard) options {search mode:grep}) -- Strip leading carraige returns if line isn't empty. May not be needed depending on logfile. If lines clump together, try disabling. If single spaced lines become double-spaced, keep enabled.
	set the clipboard to (replace "\\[0;37m(.*)\\[0m$" using ">\\1" searchingString (the clipboard) options {search mode:grep}) -- mark input lines with leading >
	do shell script "[[ $__CF_USER_TEXT_ENCODING =~ ^(.*):(.*):(.*)$ ]] && rgn=${BASH_REMATCH[3]} || rgn=0;export LC_CTYPE=UTF-8;pbpaste | perl -CS -0777 -pe 's/\\r\\n|\\r/\\n/g' | pbcopy" -- fix linefeeds - gets current region code, sets text encoding to UTF-8, and converts CR/CRLF to LF UTF code. (May or may not be needed, depending on logfile.)
	do shell script "pbpaste | /usr/local/bin/ansifilter -B -m " & colormap & " | pbcopy" -- Convert raw ANSI log in clipboard to BBcode.
	set fixedtext to (the clipboard) as text -- Now that the log is converted to BBcode, filter it for content and prettiness.
	
	(*
	-- Set bold colors to bright bold colors.  If you change the colors in the colormap, set these as well. (Not needed in newer versions of Ansifilter)
	set fixedtext to replace "[color=#990000][b]" using "[color=#E50000][b]" searchingString fixedtext -- bold red to bright bold red
	set fixedtext to replace "[color=#00A600][b]" using "[color=#00D900][b]" searchingString fixedtext -- bold green to bright bold green
	set fixedtext to replace "[color=#d9a000][b]" using "[color=#E5E500][b]" searchingString fixedtext -- bold yellow to bright bold yellow
	set fixedtext to replace "[color=#00006F][b]" using "[color=#0000FF][b]" searchingString fixedtext -- bold blue to bright bold blue
	set fixedtext to replace "[color=#B200B2][b]" using "[color=#E500E5][b]" searchingString fixedtext -- bold magenta to bright bold magenta
	set fixedtext to replace "[color=#00A6B2][b]" using "[color=#00E5E5][b]" searchingString fixedtext -- bold cyan to bright bold cyan
	set fixedtext to replace "[color=#BFBFBF][b]" using "[color=#FFFFFF][b]" searchingString fixedtext -- bold white to bright bold white
	*)
	
	-- Color cleanup
	set fixedtext to replace "\\[color=#bfbfbf\\]((.|\\n)*?)\\[/color\\]" using "\\1" searchingString fixedtext options {search mode:grep} -- strip plain white lines of color codes.
	set fixedtext to replace "\\[color=#.{6}\\](\\s*?)\\[/color\\]" using "\\1" searchingString fixedtext options {search mode:grep} --remove colors that don't color anything.
	
	-- Filters: Comment individual lines out with -- if you'd like them left in the log. 
	
	-- Channel strippers
	set fixedtext to replace "\\[color=#E50000\\]\\[b\\].*tells you,.*|\\[color=#E50000\\]\\[b\\]You tell.*|\\[color=#E50000\\]\\[b\\]You reply to.*|\\[color=#E50000\\]\\[b\\].*replies to you,.*|\\[Multiple tell, sent to:.*" using "" searchingString fixedtext options {search mode:grep} -- tells
	set fixedtext to replace "\\(visnet\\) \\[color=#0000FF\\](.*)$" using "" searchingString fixedtext options {search mode:grep} -- Visnet
	set fixedtext to replace "\\[color=#00a6b2\\]\\[\\[/color\\]OOC\\[color=#00a6b2\\]]\\[/color\\].*" using "" searchingString fixedtext options {search mode:grep} -- OOC
	set fixedtext to replace "\\[color=#FFFFFF\\]\\[b\\]\\[\\[/b\\]\\[/color\\]\\[color=#00E5E5\\]\\[b\\]Physicians\\[/b\\].*" using "" searchingString fixedtext options {search mode:grep} -- Physicians
	set fixedtext to replace "\\[color=#FFFFFF\\]\\[b\\]\\[\\[/b\\]\\[/color\\]\\[color=#666666\\]\\[b\\]Merchants\\[/b\\].*" using "" searchingString fixedtext options {search mode:grep} -- Merchants
	
	-- OOC stuff strippers
	set fixedtext to replace "\\nGaggable keepalive command." using "" searchingString fixedtext --Keepalive messages
	set fixedtext to replace "\\n[color=#00a6b2](This is an OOC room.  Nothing counts for rpxp here.)[/color]" using "" searchingString fixedtext --OOC room messages
	set fixedtext to replace "\\n\\[color=#E50000\\]\\[b\\]WARNING: Osays exist only to clarify RP and cost 5 RPXP.  Please move to tells if possible.\\[/b\\]\\[/color\\]" using "" searchingString fixedtext -- osay Warnings
	set fixedtext to replace "\\[color=#00a6b2\\]   Name    \\[/color\\]\\[color=#990000\\]: \\[/color\\]((.|\\n)*?)(character status.\\[/color\\]|affected by anything.\\[/color\\])" using "" searchingString fixedtext options {search mode:grep} -- Score
	set fixedtext to replace "\\[color=#00a6b2\\]------------------------------------------------------------------------\\n\\[/color\\]\\[color=#00E5E5\\]\\[b\\] Combat((.|\\n)*?)Backstab.*$" using "" searchingString fixedtext options {search mode:grep} -- ab com
	set fixedtext to replace "Rooms with players who have toggled WHERERP on:((.|\\n)*?)to toggle it (on|off).\\[/color\\]" using "" searchingString fixedtext options {search mode:grep} -- whererp
	set fixedtext to replace "^These are the rumors((.|\\n)*?)(\\[color=#00a6b2\\]\\[RPxp: .*)" using "\\1" searchingString fixedtext options {search mode:grep} -- Rumors- relies on prompt for Ending.
	set fixedtext to replace "^           \\S((.|\\n)*?)Please VOTE for TI on the links at https://ti-legacy.com\\[/b\\]\\[/color\\]" using "" searchingString fixedtext options {search mode:grep} -- Who list
	set fixedtext to replace "^>(look|l) (.*)$" using " >look \\2" searchingString fixedtext options {search mode:grep} -- Keep looks
	set fixedtext to replace "\\n>(.*)$" using "" searchingString fixedtext options {search mode:grep} -- Input lines
	set fixedtext to replace "\\[color=#00a6b2\\]\\[RPxp: .*" using "" searchingString fixedtext options {search mode:grep} -- Prompt
	
	set fixedtext to replace "\\n\\n\\n*" using "\\n\\n" searchingString fixedtext options {search mode:grep} -- Line normalizer. More than double lines reduced to double.
	set the clipboard to fixedtext -- Copy filtered BBcode log to clipboard for pasting.
end tell
Update: I spent the day working on a MUSHClient script, based on the TI Colour Copy script.
To install, paste the script below into Notepad and save it to MUSHclient\worlds\plugins\Copy_BBcode.xml
It can be loaded from File:Plugins --> Add

It will look for ansifilter at MUSHclient\ansifilter\ansifilter.exe, and the colormap at MUSHclient\colormap.txt
Be sure to grab the latest ansifilter from http://www.andre-simon.de/zip/download.php and unzip it to MUSHclient\ansifilter
and copy/paste the colormap above into notepad and save it to MUSHclient\colormap.txt

Code: Select all

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>

<!-- MuClient version 4.94 -->

<!-- Plugin "Copy_BBCode" generated by Plugin Wizard -->

<muclient>
<plugin
   name="Copy_BBCode"
   author="Taunya"
   id="56d2afae8c02325fcc5c191a"
   language="Lua"
   purpose="Copys output with BBcode"
   date_written="2018-05-19 10:08:09"
   requires="4.00"
   version="1.0"
   >
<description trim="y">
Copies text from the output window to the clipboard, with BBcode codes.
Based on TI Colour Copy by Nick Gammon.

To use: highlight text and then:

Ctrl+B copy (like Ctrl+C but different)

or: Ctrl + Left-click and select "Copy BBCode"

</description>

</plugin>

<aliases>
  <alias
    match="Copy_BBCode:56d2afae8c02325fcc5c191a"
    enabled="y"
    omit_from_output="y"
    sequence="100"
    script="CopyScript"
    name="Copy_BBCode"
    menu="y"
  >
  </alias>
</aliases>

<!--  Get our standard constants -->

<include name="constants.lua"/>

<!--  Script  -->


<script>
<![CDATA[
-- Thank you, Shaun Biggs, for taking your time to write the CopyScript
-- (formerly Copy2) function below. It was slightly altered by me to suit
-- my usage (wordwrapped lines and no \r\n at start of selection).


local BLACK = 1
local RED = 2
local GREEN = 3  
local YELLOW = 4 
local BLUE = 5 
local MAGENTA = 6 
local CYAN = 7 
local WHITE = 8

-- how each colour is to appear (black is not supported on Aardwolf)

local conversion = {
  [GetNormalColour (RED)]     = ANSI (0, 31),
  [GetNormalColour (GREEN)]   = ANSI (0, 32),
  [GetNormalColour (YELLOW)]  = ANSI (0, 33),
  [GetNormalColour (BLUE)]    = ANSI (0, 34),
  [GetNormalColour (MAGENTA)] = ANSI (0, 35),
  [GetNormalColour (CYAN)]    = ANSI (0, 36),
  [GetNormalColour (WHITE)]   = ANSI (0, 37),
  [GetNormalColour (BLACK)]   = ANSI (1, 30),
  [GetBoldColour   (RED)]     = ANSI (1, 31),
  [GetBoldColour   (GREEN)]   = ANSI (1, 32),
  [GetBoldColour   (YELLOW)]  = ANSI (1, 33),
  [GetBoldColour   (BLUE)]    = ANSI (1, 34),
  [GetBoldColour   (MAGENTA)] = ANSI (1, 35),
  [GetBoldColour   (CYAN)]    = ANSI (1, 36),
  [GetBoldColour   (WHITE)]   = ANSI (1, 37),
  [GetBoldColour   (BLACK)]   = ANSI (1, 30),
  }  -- end conversion table
  
function getbbcode ()

  f = assert (io.open ("bbcode.txt", "r"))
  local bbcode = f:read ("*all")
  SetClipboard (bbcode)
  f:close ()

end -- getbbcode

function DoOneLine (styles, startcol, endcol)

  -- remove unneeded style runs at the start
  while next (styles) and startcol > styles [1].length do
    startcol = startcol - styles [1].length
    endcol = endcol - styles [1].length
    table.remove (styles, 1)
  end -- do
  
  -- nothing left? uh oh
  if not next (styles) then return end
  
  -- discard unwanted part of first good style
  if startcol > 1 then
    styles [1].length = styles [1].length - startcol
    endcol = endcol - startcol + 1
    styles [1].text =  styles [1].text:sub (startcol)   
    startcol = 1
  end -- if
  
  -- copy appropriate styles and codes into the output
  while next (styles) do
    local len = endcol - startcol + 1
    
    if len < 0 or endcol < 1 then
      return
    end -- done
    
    -- last style?
    if len < styles [1].length then
      styles [1].length = len
      styles [1].text = styles [1].text:sub (1, len)
    end -- if last style
  
    -- fixup string first - change { to {{ and ~ to {-
    local text = string.gsub (styles [1].text, "{", "{{")
    text = string.gsub (styles [1].text, "~", "{-")
    
    -- put code in front, if we can find one
    local code = conversion [styles [1].textcolour]
    if code then
      copystring = copystring .. code
    end -- if code found
    
    -- now the text
    copystring = copystring .. text
    
    -- less to go now
    endcol = endcol - styles [1].length
    
    -- done this style
    table.remove (styles, 1)
    
  end -- while
  
end -- DoOneLine

function CopyScript(name, line, wildcs)

  -- find selection in output window, if any
  local first_line, last_line = GetSelectionStartLine(), 
                                math.min (GetSelectionEndLine(), GetLinesInBufferCount ())

  local first_column, last_column = GetSelectionStartColumn(), GetSelectionEndColumn()
  
  -- nothing selected, do normal copy
  if first_line <= 0 then
    DoCommand("copy")
    return
  end -- if nothing to copy from output window
  
  copystring = ""
  
  -- iterate to build up copy text
  for line = first_line, last_line do
  
    if line < last_line then
      DoOneLine (GetStyleInfo(line), first_column, GetLineInfo(line).length) 
      first_column = 1
      
      -- Is this a new line or merely the continuation of a paragraph?
      if GetLineInfo (line, 3) then
        copystring = copystring .. "\r\n"
      end  -- new line
      
    else
      DoOneLine (GetStyleInfo(line), first_column, last_column)
    end -- if
        
  end  -- for loop
  
  -- Get rid of a spurious extra new line at the start.
  if copystring:sub (1, 2) == "\r\n" then
    copystring = copystring:sub (3)
  end   -- if newline at start

  if copystring:sub (-2) ~= ANSI (0, 37) then
    copystring = copystring .. ANSI (0, 37)
  end   -- if newline at start

  
  -- finally can set clipboard contents
  -- SetClipboard(copystring)
  f = assert (io.open ("ansi.txt", "w"))  -- open file to export code
  f:write (copystring)  -- write to file
  f:close ()  -- close it

  os.execute('ansifilter\\ansifilter.exe -B -m colormap.txt -i ansi.txt -o bbcode.txt') -- run ansifilter to convert ANSI to BBcode
  
  DoAfterSpecial (2, 'getbbcode()', sendto.script)
  
end -- function CopyScript


AcceleratorTo ("Ctrl+B", "CallPlugin ('56d2afae8c02325fcc5c191a', 'CopyScript', '')", sendto.script)

]]>
</script>


</muclient>
Select text and ctrl-B, or crtl-left click and select "Copy BBCode" to copy directly to BBCode.
It seems the output will be a bit messier than from a logfile, but it should be fine for quick snipplets!
Disclaimer: I don't use MUSHclient, so I can't guarantee it'll work perfectly.
Last edited by Taunya on Sat May 19, 2018 6:41 pm, edited 6 times in total.

User avatar
Kinaed
Posts: 1984
Joined: Wed Jan 05, 2011 8:54 pm
Discord Handle: ParaVox3#7579

Wed May 16, 2018 12:30 am

<3

User avatar
Niamh
Posts: 1070
Joined: Wed Nov 30, 2016 9:04 pm
Discord Handle: Niamh#3824

Sat May 19, 2018 9:52 am


Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 16 guests