02-23-2016 01:54 PM
Is there a way to change the color of the text written to the EG log? I'm using SAS EG, Brontosaurus version -- oops , I mean version 4.3. No, I don't know why my company is stuck in the Mesozoic era; believe me I've complained. The version of SAS we're using is 9.3.
Yes, I know about using NOTE, WARNING, and ERROR. I see something called Message in the EG editor options, but a quick try of
PUTLOG "MESSAGE: Is this text colorized?";
didn't produce any colorization.
I'm basically looking for a way to make certain user created messages to stand out from all the other NOTE messages without triggering an error or warning. Googling SAS Dummy and Communities doesn't turn up anything.
Thanks for any help,
02-23-2016 02:20 PM
Interesting question. If it can't be done now, please submit it as a SASware Ballot Idea.
Personally, I color notes as blue, warnings as reverse green, and errors as reverse-red.
For user-generated notes I either use NOTE: prefix which will make them blue like the SAS generated notes, or leave them as default black. The black is unusual enough to catch my attention most of the time, because it's the only black text that is not indented:
And of course if it's essential that it catch my attention, I just make it an error. Often I use NOTE: (USER) or EROR: (USER) so that I can distinguish the user-generated messages from SAS-generated messages.
That said, if there were an easy way to customize a coloring scheme for user-generated messages, that would be nice.
02-23-2016 07:56 PM
Yeah, normally, the basic SAS EG color scheme is fine. Occasionally, I want to display some type of message that while not an error needs to stand out. I could use ERROR: but then that changes which programs execute within my workflow.
Here's an example of a user supplied series of Notes. Everything is in green since it's all generated by "NOTE:" or "NOTE-". I was hoping there was some other prefix like "USER" or some such that I could use to set apart particular messages, such as the dates and ages in the below example. Looks like I'm out of luck. I'll look into the SAS ballot.
By the way the the SAS supplied age calculation -- int(yrDif(birthDate, asOfDate, 'AGE')) ; -- doesn't work correctly if person is born on February 29th. It will increment their age on February 28th even in Leap Years.
02-24-2016 02:23 AM
The SAS log is a simple text file, with no formatting at all. This will stay that way, as changing that would break a gazillion of things.
The colouring is done by the agent displaying the log, as it interprets the semantics of the log messages.
So the simple answer to your question is a clear "no".
What you could do is write some kind of utility that reads a log, converts it to a file format that does contain formatting (ie HTML), and add formatting tags depending on the content of the log. That is what the log display in EG does internally.
02-24-2016 02:56 AM
Interesting idea, Kurt. One could also use something like TextPad (not NotePad, not WordPad) or perhaps UltraEdit. These are configurable as to their colorization, and if I recall correctly rules can be added to colorize things like lines beginning with "USER:" or some such. If one were to use PRINTTO and then pull the log into one of these editors, then one would have the desired results. This of course requires a bit more programming and a bit more manual intervention.
Still might be a good suggestion for a SAS ballot although I can't imagine it would be a big priority.
Of course the other alternative if there's a "must see" message in the log is to simply email it to oneself.
02-24-2016 03:13 AM
Since all that you want takes place inside EG, I also suggest you start a ballot.
Request that users can add their own patterns (regexp?) for recognization by the Enhanced Editor so that a distinct coloring of certain log entries can be achieved.
I do specific evaluation of batch job logs in the wrapper sasbatch script (using grep) to catch certain messages that indicate fault conditions which would otherwise go undetected (ie certain mainframe-specific FTP status codes)
02-24-2016 07:56 AM
Here's the way that coloring happens in the EG log viewer.
SAS generates a SAS log in which each log line has a two-byte indicator that tells us "what type" of line it is: Normal, Note, Error, Warning, and so on. I've described this in a paper about building your own SAS client app - look for the section titled "FETCHING THE COLOR-CODED SAS LOG AND LISTING".
So if you want to achieve custom coloring that is attached to the "Message" line type in your preferences, you need to convince SAS to emit a log line that is categorized with the Message type. But I don't know how to force a "Message" line type to the log. I'll check with some experts here to see if it can be done from within a SAS program.
02-24-2016 09:17 AM
Were that possible (causing SAS EG to set the two byte color indicator from within a SAS program), that would be fantastic. I look forward to what you may find out.
02-24-2016 09:31 AM
I did learn something, but it's not the answer. Sharing in case it's helpful to you.
SAS has a facility called Log4SAS that was added in SAS 9.2. You can use it to direct custom messages to your log at various levels of detail. It's also used by SAS to help diagnose issues encountered by customers.
filename rev1 temp; %log4sas(); %log4sas_appender(testout, "FileRefAppender", 'fileref=rev1'); %log4sas_logger(logger, 'level=trace appender-ref=(testout)'); %log4sas_info(logger,"Test INFO message"); %log4sas_debug(logger,"Test DEBUG message"); %log4sas_trace(logger,"Test TRACE message"); %log4sas_warn(logger,"Test WARNING message"); %log4sas_error(logger,"Test ERROR message"); %log4sas_fatal(logger,"Test FATAL message");
Alas, while the WARNING, INFO, ERROR, and FATAL produce the usual colored lines, DEBUG and TRACE do not -- they use the "Normal" line type in the log.
Still checking, but don't hold out much hope that your SAS program can generate a "Message" type log entry. This type might be used more by interactive SAS and not the SAS language service that is utilized by clients like EG.
02-25-2016 02:27 AM - edited 02-25-2016 02:33 AM
Intersting. log4SAS works great on my University Edition SAS (v 9.4) at home. Didn't work at my office. Must be some setting. I used the custom task that you posted on Dummy some time ago to show the settings, and option MAUTOSOURCE appeared to be in operation, but no go.
Log4SAS is a nice little option in that it writes simultaneously to the SAS log as well as to an external log file. Would that it would colorize the content of the log however (beyond the standard three: NOTE, WARNING, and ERROR).
If you come up with anything, I would love to hear it, but no worries inasmuch as there are multiple work arounds including parsing routines for the log, emailing messages to oneself, etc.
It would of course be a wonderful "someday" enhancement to SAS EG to have a message type reserved exclusively for the user where all one had to do is prefix said message with something like "MESSAGE:" much like one would do with "NOTE:" (etc.) today. Thus, one could easily pick out messages that were specifically written by the application programmer both by color and by textual content. It would also be nice if SAS EG could dispense soft serve ice cream on a hot day. Neither wish is necessarily reasonable, but I hope that at least one of the two will come true.