Skip to content

Documentation: Loggers

squirrelforce edited this page Oct 31, 2013 · 22 revisions

The API exposes RESTful endpoints for maintaining individual logger for each account in Papertrail via their Distributor API. For example, for CloudSpokes, a member will have a Papertrail account and a logger for each challenge to which they've submitted. Using SSO, members can open their Papertrail account and switch to different challenge submissions (loggers) from the Dashboards link. The API allows Thurgood to create and delete loggers. Logger info is stored in the db.

Creating a Logger

curl -v -H 'Authorization: Token token="[API-KEY]"' -X POST -d name=challenge1 -d loggerAccountId=52530af66664cc351f000001 http://thurgood-staging.herokuapp.com/api/1/loggers

Required parameters:

  • name - the human-readable name of this logger. Spaces and punctuation are accepted. This is the name that displays in Dashboard link in Papertrail. This is typically the challenge name, ParticipantId, Challenge_Id or some other identifier.
  • loggerAccountId - the id of the associated account in the local database (not Papertrail). This is only used in the local database.

Optional parameters:

  • papertrailId - the id of the Papertrail logger to be created. If a value is not specified, then an ID will be created. You may want to specify your own ID if you would like to submit multiple jobs to the same logger system. This is the id of the logger in Papertrail.

The operation is idempotent and will not create multiple loggers when the same information is submitted. An existing logger will be returned instead.

Response:

{
   "success":true,
   "data":[
      {
         "_id":"52531d740d899bbe21000002",
         "createdAt":1381178740874,
         "loggerAccountId":"52530af66664cc351f1111111",
         "name":"challenge1",
         "papertrailAccountId":"testabcdz",
         "papertrailId":"5bcd9e3707c0e8bf00c1837d6130336fe248f20a96a57824",
         "syslogHostname":"cloudspokes1.papertrailapp.com",
         "syslogPort":11111,
         "updatedAt":1381178740874
      }
   ]
}

Fetching a Logger

curl -v -H 'Authorization: Token token="[API-KEY]"' http://thurgood-staging.herokuapp.com/api/1/loggers/:id

Required parameters:

  • id - the UUID (_id) of the logger

Response:

{
   "success":true,
   "data":[
      {
         "_id":"525868e1dff10c1259000777",
         "createdAt":1381525729888,
         "loggerAccountId":"52530af66664cc351f001987",
         "name":"testabcdz",
         "papertrailId":"testabcdz",
         "syslogHostname":"cloudspokes1.papertrailapp.com",
         "syslogPort":52700,
         "updatedAt":1381525729888
      }
   ]
}

Deleting a Logger

curl -v -H 'Authorization: Token token="[API-KEY]"' -X DELETE http://thurgood-staging.herokuapp.com/api/1/loggers/:id

Required parameters:

  • id - the UUID (_id) of the logger

Response:

{
   "success":true,
   "message":"Logger deleted successfully"
}

If the logger did not exist in Papertrail or an error occurred the response will be something like:

{
   "success":false,
   "message":"Logger not found",
   "error":"Logger not found"
}