Summary:

Sage CRM is capable of generating detailed logging information. This can be of use when troubleshooting an issue, or when developing a customisation. This knowledgebase article describes a method of adding syntax highlighting and troubleshooting tools for the core ewaresystem and ewaresql logs, as well as JS and ASP files. These tools have been developed for TextPad 7. Installing these tools is recommended if you find yourself wishing to inspect the Sage CRM logs on a regular basis.

Once installed, the modified copy of TextPad will display Sage CRM system logs as follows: 

 TextPad screenshot 

These tools and instructions are provided as-is, and no support will be provided for them by Sage. That said, feedback and suggestions are welcome, and should be provided either via the Sage CRM Community or through your local support team.

More information:

The attachments given are for a 64-bit copy of TextPad 7. While the syntax definition files and tools will work with earlier versions of TextPad, the settings file will not. TextPad 7 x64 can be downloaded here.

The following files are required:

 Download: Syntax files
 Download: CRM TextPad tools
 Download: TextPad 7 user config

Once downloaded, carry out the following steps:

  1. After installing TextPad 7, open, then close the application. This will serve to initialise the user settings.
  2. Next, extract the contents of Syntax files.zip to c:\Program Files\TextPad 7\Samples.
  3. Create a new directory named Tools under the c:\Program Files\TextPad 7\ directory.
  4. Extract and copy the contents of TextPad tools - external distribution.zip to this directory.
  5. Extract the contents of TextPad 7 CRM Tools conf.zip to c:\Users\<user>\AppData\Roaming\Helios\TextPad\7\, replacing any existing files that are in that directory.

On completing the bove, you should be able to open TextPad and make use of the syntax highlighting and log analysis tools.

Advanced:

The following instructions are provided for information purposes. Should an issue occur when adding the TextPad custom settings using the method above, the following manual steps can be followed.

Install a copy of TextPad 7 x64.

Open TextPad, then close all windows and sidebars, (this is optional, but will serve to declutter the screen when examining CRM logs). Close the application.

Extract and copy the crmlogs.syn and crmdev.syn syntax files from Syntax files.zip to C:\Program Files\TextPad 7\Samples.

Open TextPad 7.

Go to Configure > Preferences.

Under the File menu, set the When files are modified by another process option to Ignore.

Under the View menu, untick the Highlight the line containing the cursor option. Tick the Line numbers option.

Navigate to Document Classes > HTML.

Remove ASP, HTM and HTML from the HTML document class. Remove JS from the JavaScript document class.

Create two new document classes, called CRM Dev and CRM Logs.

 

CRM Dev document class

In the CRM Dev document class, add the following filetypes:

*.asp
*.js
*.es
*.config
*.inc
*.htm

Set the default encoding to be UTF-8.

Expand the document class and select the Syntax menu option. Tick the Enable syntax highlighting checkbox.

Select the crmdev.syn syntax definition file. Hit Apply.

The following settings are optional, and will result in TextPad displaying CRM logs with light text on a dark background. This may or may not be to your liking.

Colours (RGB values):

Window background:          51, 51, 51
Bookmarks:                  255, 255, 0
Brackets:                   152, 251, 152
Characters:                 255, 160, 160
Comments:                   135, 206, 235
Comments 2:                 109, 109, 109
Current line:               255, 255, 0
Keywords 1:                 152, 251, 152
Keywords 2:                 240, 230, 140
Keywords 3:                 152, 251, 152
Keywords 4:                 152, 251, 152
Keywords 5:                 240, 230, 140
Keywords 6:                 189, 183, 107
Left margin:                109, 109, 109
Numbers:                    240, 230, 140
Operators:                  255, 222, 173
Page breaks:                109, 109, 109
Preprocessor keywords:      128, 160, 252
Selected text:              Fore: 240, 230, 140 Back: 107, 142, 35
Selected text (no focus):   Fore: 240, 230, 140 Back: 107, 142, 35
Strings:                    255, 160, 160
Text:                       255, 255, 255
URL:                        128, 160, 255
Visible spaces:             109, 109, 109

Font:                       Fixedsys size 9

Tabulation:                 Default tab spacing: 4
                            Indent size: 4

 

CRM Logs document class

In the CRM Logs document class, add the following filetypes:

*ewaresql*
*ewaresystem*
*.log
*.elf

Set the default encoding to be UTF-8.

Expand the document class and select the Syntax menu option. Tick the Enable syntax highlighting checkbox.

Select the crmlogs.syn syntax definition file.

Again, the following settings are optional:

Colours (RGB values):

Window background:          51, 51, 51
Bookmarks:                  255, 255, 0
Brackets:                   152, 251, 152
Characters:                 135, 206, 235
Comments:                   Fore: 51, 51, 51  Back: 255, 204, 0
Comments 2:                 Fore: 51, 51, 51  Back: 255, 204, 0
Current line:               255, 255, 0
Keywords 1:                 189, 183, 107
Keywords 2:                 135, 206, 235
Keywords 3:                 240, 230, 140
Keywords 4:                 152, 251, 152
Keywords 5:                 Fore: 255, 255, 255 Back: 255, 0, 0
Keywords 6:                 255, 160, 160
Left margin:                109, 109, 109
Numbers:                    234, 234, 234
Operators:                  255, 222, 173
Page breaks:                109, 109, 109
Preprocessor keywords:      0, 0, 255
Selected text:              255, 255, 255
Selected text (no focus):   255, 255, 255
Strings:                    135, 206, 235
Text:                       255, 255, 255
URL:                        255, 255, 0
Visible spaces:             109, 109, 109

Font:     Tahoma size 10 

 

Log analysis tools

Create a new Tools directory under c:\Program Files\TextPad 7\, and extract the contents of TextPad tools - external distribution.zip to that directory. Tools can be added in the Configure > Preferences menu option in TextPad.

 

Tool 1: Show errors

This tool displays errors found in the ewaresystem and ewaresql log files. Double-clicking on an entry in the Results pane will take you to the relevant section in the source log file.

If the system logging level is set to 5 (maximum), an attempt will be made to identify which user action has been the source of the error. This is done using the thread ID and process ID in the log files.

DOS command:

wscript showerrors.js "$File"

Initial folder:

C:\Program Files\TextPad 7\Tools

Additional options:

Capture output

Regular expression to match output:

^Line ([0-9]+)

Register: Line 1

When done, the tool settings should look like this:

Show errors settings

 

Tool 2: Show long queries

This tool can be executed against the system or SQL logs. By default, it will show all actions or SQL statements that took more than 5000ms to complete. This value can be changed by editing showlongqueries.js.

DOS command

wscript showlongqueries.js "$File"

Initial folder:

C:\Program Files\TextPad 7\Tools

Additional options:

Capture output

Regular expression to match output:

^Line ([0-9]+)

Register: Line 1

Long queries tool setup

Tool 3: Show long queries (slow)

This is similar to the previous tool, except that it carries out more reads on the log file rather than load the whole log as a single block into RAM. It’s slower, but may be necessary when looking at very large log files.

DOS command

wscript showlongqueries_slow.js "$File"

Initial folder:

C:\Program Files\TextPad 7\Tools

Additional options:

Capture output

Regular expression to match output:

^Line ([0-9]+)

Register: Line 1

Show long queries slow setup