Jump to content

P4Api use -zversion and -zprog to create custom loggings

p4api logging

  • Please log in to reply
1 reply to this topic

#1 madowen



  • Members
  • Pip
  • 1 posts

Posted 27 January 2020 - 12:00 PM


I have created a small app on C# and I am using the P4Api, I need to add this 2 parameters so the server logs shows from where the commands are coming, as it is explained on this post: https://community.pe...s/article/11551

As I am using the P4Api, this is the line to create the perforce command:

string logParams = $"-zprog=MyApp -zversion={Assembly.GetEntryAssembly().GetName().Version.ToString()}";
P4Command cmd = new P4Command(rep, "sync", false, path);

I have tried to add the logParams after the path as arguments, but the sync command recognize them as if they were another path to a file, returning a "no such files(s)" message error.
I also tried to add them before the "sync" (using the cmd would be "p4 -zprog=MyApp - zversion=0.0.1 sync path" ), but it recognize them as a command so it returns an unknown command message error.

Is there a way to add this parameters using the P4API?


#2 p4bill


    Advanced Member

  • Members
  • PipPipPip
  • 217 posts

Posted 12 February 2020 - 06:52 PM

With p4api.net you cannot pass the -zprog or -zversion flags with commands. But, these can be set in the connection options:
Options options = new Options();
options["ProgramName"] = "Test Program";
options["ProgramVersion"] = "1.0.0";
When any commands are run with that connection [Test Program/1.0.0] will show in the server log.

Also tagged with one or more of these keywords: p4api, logging

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users