Aller au contenu

Photo

TUTORIAL: Turning on logging


11 réponses à ce sujet

#1
kilrex

kilrex
  • Members
  • 69 messages
If there's a better version of this, can someone sticky it for this forum. Being able to add logging to any new code is almost essential for debugging problem.



1) Enable Logging (for Scripts at the Least)

In the DAO bin_ship directory where the dao executables are placed, create a file named

      ECLog.ini

In it you should place the following 2 lines at least:

    [LogTypes]
    Script=1

If you want to see a more complete version of the file look at this link on the toolset wiki

http://social.biowar...x.php/ECLog.ini


This
will turn on logging, for scripts.
At the very minimum, your log file will now display all changes to plot flags. But not much more except maybe a forgotten script logging statement or 2.

2) Add Logging to Your Script(s)

Now go to your script and start using the function

    PrintToLog()

All over the place. Not that is is a fairly basic Print command, and does not automatically convert number types to strings. So you will have to use IntToString() a lot, and probably FloatToString as well.
But strings can still be concatenated using the + operator.

Here is a simple snippet

            PrintToLog("*****************************");
            PrintToLog("EVENT_TYPE_MODULE_LOAD seen.");
            PrintToLog("*****************************");

Here is an example that reports the values of some variables along with some text

PrintToLog(IntToString(j) + " :: " + sTag + ":Prop=" + IntToString(tmpProp) + ":New=" + IntToString(newPower) + ":Old=" + IntToString(curPower));

This just prints something like

    12 :: gen_item_acc_foo :: Prop=1001 :: New=3 :: Old=1

It's there just to provide an more complex example of stringing to get strings and non string values.

Pointer:
The log file will probably have a fair amount of data to dig through. So you probably want to do something to make your own statements stand out.
The first snippet above does that by prints the ********** out before and after the information reported.
So you may want to consider doing that for all your logging.
If you want to make it easier add something like this function to the start of each script or something included in each.
(Edit to to fit your own aesthetic)


void PrintVisibleMsg(string logMessage)
{
            PrintToLog("******LOOK HERE!!! LOOK AT ME!! LOOK !!! PAY ATTENTION TO ME!!!");
            PrintToLog(logMessage);
            PrintToLog("******LOOK HERE!!! LOOK AT ME!! LOOK !!! PAY ATTENTION TO ME!!!");

}

Though I find just PrintToLog("*****************************"); easier on the eyes myself.


3) Run the Game, then Review Your Log

Now that you have added logging statements, run the game and then check the log file.
The log file is named:

    DragonAge_1.log

And this time, the file is located in your "My Documents" folder. Specifically under

    BioWare\\Dragon Age\\Logs

The log file will have a fair amount of data. The first step to locating you own logging is to remember that all script logging will have the word

Script

Followed by a tab character prefixed to them.
If you turn on other options for logging, each other option should have it's own channel name as its prefix instead.


Here is a sample of some of the many plot flag lines you will

Script    GetPlot [gen00pt_class_race_gend] [GEN_RACE_HUMAN] = [ DEFINED ]
Script    GetPlot *DEFINED* [gen00pt_class_race_gend] [GEN_RACE_HUMAN] [value of DEFINED flag after evaluation: 0]
Script    GetPlot [gen00pt_class_race_gend] [GEN_RACE_HUMAN] = [ DEFINED ]
Script    GetPlot *DEFINED* [gen00pt_class_race_gend] [GEN_RACE_HUMAN] [value of DEFINED flag after evaluation: 0]
Script    SetPlot [genpt_app_alistair] [APP_ALISTAIR_INC_LOW] [0 -> 1]

The first snippet provide results in something like this: Notice that if you do not do something to make your information stand out, it may be a little tedious to find what you want.

Script    GetPlot [gen00pt_backgrounds] [GEN_BACK_ELF_DALISH] = [0]
Script    GetPlot [gen00pt_backgrounds] [GEN_BACK_DWARF_COMMONER] = [0]
Script    GetPlot [gen00pt_backgrounds] [GEN_BACK_DWARF_NOBLE] = [0]
Script    TrackSendGameId: Game ID is 2390500303 FromStart: 0
Script    *****************************
Script    EVENT_TYPE_MODULE_LOAD seen.
Script    *****************************
Script    GetPlot [gen00pt_backgrounds] [GEN_BACK_HUMAN_NOBLE] = [0]
Script    GetPlot [gen00pt_backgrounds] [GEN_BACK_ELF_CITY] = [0]
Script    GetPlot [gen00pt_backgrounds] [GEN_BACK_ELF_DALISH] = [0]
Script    GetPlot [gen00pt_backgrounds] [GEN_BACK_DWARF_COMMONER] = [0]
Script    GetPlot [gen00pt_backgrounds] [GEN_BACK_DWARF_NOBLE] = [0]
Script    TrackSendGameId: Game ID is 2390500303 FromStart: 1

#2
Talian Kross

Talian Kross
  • Members
  • 239 messages
Déjà vu.

:whistle:

#3
kilrex

kilrex
  • Members
  • 69 messages
mostly I'm hoping someone will take one of the logging posts and sticky it.

#4
Sunjammer

Sunjammer
  • Members
  • 925 messages
No need for a sticky: the information is on the wiki.

#5
kilrex

kilrex
  • Members
  • 69 messages
I look at this way



How much effort would it take to sticky a few threads that provide people pointers and some basics essential to debugging script?

Very little it would seem to me.



So where is the harm?

And the benefit is that it helps people who don't end up on the wiki first, otherwise they might not even be here...



So it costs us very little, and it potentially helps many or even just a few people.

To me this seems like a win.





OR

We can take the the more typical view and do nothing, not even have a pointer to the wiki...

So all those people that do come here first, don't have a few simple pointers very obviously placed



In this case, it costs us nothing, but it costs other people who need help.

So, is this a win then from this point of view?



So if a new user to the toolset comes to the script forum for help, please point out where they can see an obvious link for the wiki

or any pointers or useful places to start looking for help




#6
kilrex

kilrex
  • Members
  • 69 messages
I could care less who is the author of basic starting info, I just see that it's not here, and for so little cost, it will probably help lots of people.

See, again, spend just a little to maybe help people

or spend nothing to definitely NOT help people

which makes more sense?

Sorry, but I deal with people at work who are idiots who respond this way all the time, and it gets irritating when they then complain about how hard it is to find information to help themselves out, ect...

#7
Sunjammer

Sunjammer
  • Members
  • 925 messages
Clogging up the forum with pointless stickies that merely duplicate or link to information already contained in the wiki will not benefit anyone in the long run: that alone should be self evident.

#8
ladydesire

ladydesire
  • Members
  • 1 928 messages
The link to the wikis for the game are along the top bar of the site, for what it's worth. I think what the others are trying to say is, if you allow one sticky for a tutorial like this, you will see others being requested, which will defeat the purpose of having a toolset wiki in the first place. Looking at it from that point of view, wouldn't you say that Bioware's (or was it EA) investment in the Social site would have been a waste of time and money; if all we wanted was a series of forums with stickies for information, we could have used the old DA forums for that.

#9
Aslend

Aslend
  • Members
  • 63 messages
The Wiki vs the Social site, hmm, nice topic, but not what is the title here. As to a sticky, I think a tutorial with all of these aspects included in a far more literary and discriptive form would be best, especially if the general player audience is trying to be reached. From my poin of view the toolset, thus far, is not a general player tool, but for the seriously experienced game developer or programmer only. The information on logging given here is excellent, but things may improve with this and a sticky would limit any such changes or additions.

#10
AnTeevY

AnTeevY
  • Members
  • 109 messages
This is really on the wiki? I tried to search for some logging information there but was unable to find it.

#11
Sunjammer

Sunjammer
  • Members
  • 925 messages
Follow the first link in the thread (social.bioware.com/wiki/datoolset/index.php/ECLog.ini) and then follow the "see also" link at the foot of that page (social.bioware.com/wiki/datoolset/index.php/PrintToLog) and you should have all the information you require (without all the unnecessary exposition).

Modifié par Sunjammer, 12 décembre 2009 - 05:03 .


#12
BryanDerksen

BryanDerksen
  • BioWare Employees
  • 273 messages
What I usually do when I do a search for something on a wiki and then find the information under a non-obvious title is to create a redirect for my original search term. In this case, for example, I just redirected [[logging]] to [[PrintToLog]]. Now anyone who searches for "logging" will be taken straight there, and people can link to it more easily.



If you wished, you could copy and paste your tutorial to [[Logging]] instead (go to http://social.biowar...ing&redirect=no to edit the existing redirect). Nothing wrong with lots of detail on the wiki, provided there are overviews and summaries as well for people who want to get straight to the heart of the matter.