BookmarkSubscribeRSS Feed
jimbarbour
Meteorite | Level 14

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.

SAS_EG_Editor_Options_Log.jpg


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,

 

Jim

10 REPLIES 10
Quentin
Super User

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:

 

logcolor.JPG

 

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.

 

 

The Boston Area SAS Users Group is hosting free webinars!
Next up: Joe Madden & Joseph Henry present Putting Power into the Hands of the Programmer with SAS Viya Workbench on Wednesday Nov 6.
Register now at https://www.basug.org/events.
jimbarbour
Meteorite | Level 14

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.

 

SAS_EG_Color_Example.jpg

Kurt_Bremser
Super User

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.

jimbarbour
Meteorite | Level 14

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.

 

Jim

Kurt_Bremser
Super User

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)

ChrisHemedinger
Community Manager

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.

Learn from the Experts! Check out the huge catalog of free sessions in the Ask the Expert webinar series.
jimbarbour
Meteorite | Level 14

Chris,

 

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.

 

Jim

ChrisHemedinger
Community Manager

Jim, 

 

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.

 

Learn about Log4SAS here.

 

Example program:

 

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.

Learn from the Experts! Check out the huge catalog of free sessions in the Ask the Expert webinar series.
jimbarbour
Meteorite | Level 14

It doesn't look like I have that option (of using SAS4log) here at work.  I'll have to try it on my own machine when I get home this evening.

 

Jim

jimbarbour
Meteorite | Level 14

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.  🙂 

 

Thanks,

 

Jim

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 10 replies
  • 5080 views
  • 6 likes
  • 4 in conversation