Overview

Namespaces

  • Jlab
    • Eloglib

Classes

  • Attachment
  • FileAttachment
  • Logentry
  • LogentryUtil
  • URLAttachment
  • User

Exceptions

  • InvalidXMLException
  • IOException
  • LogentryException
  • LogRuntimeException
  • ServerException
  • UserException
  • Overview
  • Namespace
  • Class

Class Logentry

Class Logentry

An electronic log book log entry.

Namespace: Jlab\Eloglib
Package: Jlab\Eloglib
Located at Logentry.php
Methods summary
public
# __construct( )

Instantiate a Logentry

Instantiate a Logentry

For maximum flexibility, the constructor can accept any of the following arguments:

  1. A DOMDocument or DOMElement object in Logentry.xsd format
  2. The name of an XML file in Logentry.xsd format
  3. A title and the name of a logbook (e.g. ELOG, TLOG, etc.)
  4. A title and an array of logbook names

Link

https://logbooks.jlab.org/schema/Logentry.xsd
https://github.com/JeffersonLab/elog
protected
# constructFromScratch( $title, $logbooks )

Minimal initialization private constructor.

Minimal initialization private constructor.

Automatically sets the created and author fields based on the system clock and os username respectively.

Parameters

$title
$logbooks
public
# setTitle( string $title )

Sets the title.

Sets the title.

The title is limited to max 255 characters.

Parameters

$title

Throws

Jlab\Eloglib\LogentryException
public
# setLogbooks( mixed $logbooks )

Sets the logbook(s) to which entry belongs

Sets the logbook(s) to which entry belongs

Parameters

$logbooks
(logbook name or array of logbook names)
public
# addLogbook( string $logbook )

Adds a logbook to the list of logbooks for the entry.

Adds a logbook to the list of logbooks for the entry.

Parameters

$logbook

Link

https://logbooks.jlab.org/logbooks
public
# setCreated( mixed $date )

Sets the internal timestamp of the entry.

Sets the internal timestamp of the entry.

Stores it as string in ISO 8601 date format ex: 2004-02-12T15:19:21+00:00

Parameters

$date
unix integer timestamp or string parsable by php strtotime()
protected
# setDefaultAuthor( )

Defaults the author to the user who owns the current CPU process.

Defaults the author to the user who owns the current CPU process.

public
# setAuthor( string $username, array $attributes = array() )

Sets the author.

Sets the author.

Parameters

$username
$attributes
associative array of additional user attributes
public
# setConfig( string $dir, string $file, boolean $overload = false )

Loads configuration from a .env file.

Loads configuration from a .env file.

Defaults to the .env file included with the package. Throws if required environment variables are not set.

Parameters

$dir
$file
$overload
whether config file should replace existing settings (def: FALSE)

Throws

Jlab\Eloglib\LogentryException
if required environment variables not present
public
# addEntryMaker( string $username, array $attributes = array() )

Adds an entry maker.

Adds an entry maker.

Parameters

$username
$attributes
associative array of additional user attributes
public
# addNotify( $email )

Adds an email adress to notify of the logentry

Adds an email adress to notify of the logentry

Parameters

$email
public
# addReference( string $type, integer $ref )

Adds a reference to external data

Adds a reference to external data

Parameters

$type
(lognumber, atlis, etc.)
$ref
(numeric elog_id, task_id, etc.)
public
# addTag( string $tag )

Adds a tag from the tags vocabulary

Adds a tag from the tags vocabulary

Parameters

$tag

Link

https://logbooks.jlab.org/tags
public
# setBody( string $text, string $type = 'text' )

Sets the body and its content type.

Sets the body and its content type.

Parameters

$text
The content to place in the body
$type
Specifies the formatting of text: text|html
public
# setLognumber( integer $num )

sets the lognumber.

sets the lognumber.

The lognumber will generally be set only when a logentry is retrieved from the logbook server, not during creation of a new entry.

The server will reject submissions of new entries with non-null lognumber except from a small set of privileged users. Those users would typically specify the lognumber for a new entry only in situations such as importing legacy data.

Parameters

$num
public
# addAttachment( string $filename, string $caption = '', string $type = '' )

Adds an attachment from a file.

Adds an attachment from a file.

Stores it in the object's attachments array as a base64 encoded string.

Parameters

$filename
$caption
$type
Specify a mime_type (defaults to autodetect)

Throws

public
# addAttachmentURL( string $url, string $caption = '', string $type = '' )

Adds an attachment as a URL reference.

Adds an attachment as a URL reference.

Parameters

$url
$caption
$type
mimeType

Throws

public string
# getXML( string $name = 'Logentry' )

Return Logentry object as an XML text string

Return Logentry object as an XML text string

Parameters

$name
A name to use for the encompassing XML tag.

Returns

string
protected
# xmlWriteLognumber( xmlWriter $xw )

Write the lognumber to XML.

Write the lognumber to XML.

Parameters

$xw
protected
# xmlWriteTitle( xmlWriter $xw )

Write the title to XML.

Write the title to XML.

Parameters

$xw
protected
# xmlWriteCreated( xmlWriter $xw )

Write the created timestamp to XML.

Write the created timestamp to XML.

Parameters

$xw
protected
# xmlWriteAuthor( xmlWriter $xw )

Write the author timestamp to XML.

Write the author timestamp to XML.

Parameters

$xw
protected
# xmlWriteLogbooks( xmlWriter $xw )

Write the logbook names to XML.

Write the logbook names to XML.

Parameters

$xw
protected
# xmlWriteTags( xmlWriter $xw )

Write the tag names to XML.

Write the tag names to XML.

Parameters

$xw
protected
# xmlWriteEntrymakers( xmlWriter $xw )

Write the entrymakers to XML.

Write the entrymakers to XML.

Parameters

$xw
protected
# xmlWriteBody( xmlWriter $xw )

Write the body content and type to XML.

Write the body content and type to XML.

Parameters

$xw
protected
# xmlWriteNotifications( xmlWriter $xw )

Write the email notification recipients to XML.

Write the email notification recipients to XML.

Parameters

$xw
protected
# xmlWriteReferences( xmlWriter $xw )

Write the external data references to XML.

Write the external data references to XML.

Parameters

$xw
protected
# xmlWriteAttachments( xmlWriter $xw )

Write the attachments to XML.

Write the attachments to XML.

Parameters

$xw
public integer
# submit( )

Submit the log item directly to the server and return the assigned log number, but fall back to use the queue mechanism as plan B.

Submit the log item directly to the server and return the assigned log number, but fall back to use the queue mechanism as plan B.

If the log number returned is zero it indicates the submission was queued instead of being accepted by the server. You can use the whyQueued method to obtain the ServerException encountered if any while attempting to submit directly to the server.

Returns

integer
The log number, zero means queued

Throws

Jlab\Eloglib\LogentryException
public mixed
# queue( )

Submit the log item using the queue mechanism only.

Submit the log item using the queue mechanism only.

Returns

mixed
the filename that was queued or false for failure.

Throws

Jlab\Eloglib\IOException
if unable to write queue file
Jlab\Eloglib\InvalidXMLException
public integer
# submitNow( )

Submit the log item using only the direct submission method with no queue fallback.

Submit the log item using only the direct submission method with no queue fallback.

If an error occurs during submission then an Exception will be thrown instead of falling back to the queue method.

Returns

integer
The log number

Throws

public
# whyQueued( )

Return the ServerException which prevented direct submission to the server on the most recent attempt, or null if none.

Return the ServerException which prevented direct submission to the server on the most recent attempt, or null if none.

This method allows access to the exception which is masked when the submit method is called and returns with a zero value indicating the submission was queued.

public mixed
# __get( string $var )

Magic method controls access to class properties.

Magic method controls access to class properties.

Parameters

$var

Returns

mixed
Properties summary
protected Dotenv\Dotenv $config
#
protected integer $lognumber

The log number

The log number

This number is null for a new entry and non-null for an entry retrieved from the logbook server.

#
protected string $title

The log entry title. 255 character limit imposed by Drupal database.

The log entry title. 255 character limit imposed by Drupal database.

#
protected stdClass $author

The author of the logentry

The author of the logentry

#
protected string $created

The log entry time Needs to be in ISO 8601 date format (ex: 2004-02-12T15:19:21+00:00)

The log entry time Needs to be in ISO 8601 date format (ex: 2004-02-12T15:19:21+00:00)

#
protected integer $sticky

Whether the logentry should be sticky at the top of lists

Whether the logentry should be sticky at the top of lists

#
protected string $body

The log entry body

The log entry body

#
protected string $bodyType

Indicates the formatting of the text in $body.

Indicates the formatting of the text in $body.

Valid values will correspond to text formats defined in Drupal examples: plain_text, filtered_html, full_html, etc.

#
protected array $logbooks

The list of logbooks for the entry

The list of logbooks for the entry

# array()
protected array $attachments

The list of attachments for the entry

The list of attachments for the entry

# array()
protected array $entrymakers

The list of users credited with making the entry

The list of users credited with making the entry

# array()
protected array $tags

The list of tags associated with the log entry. Must be valid terms from the tags vocabulary

The list of tags associated with the log entry. Must be valid terms from the tags vocabulary

# array()
protected array $opspr_events

The possible list of opspr events

The possible list of opspr events

# array()
protected $pr

The object that holds fields of a new-style ProblemReport (PR)

The object that holds fields of a new-style ProblemReport (PR)

#
protected array $downtime

The possible downtime fields

The possible downtime fields

# array()
protected array $references

References to external databases

References to external databases

# array()
protected array $notifications

Notifications to send

Notifications to send

# array()
protected array $comments

Comments attached to the Logentry

Comments attached to the Logentry

# array()
protected $revision_reason

Text to log as reason for a new revision

Text to log as reason for a new revision

#
API documentation generated by ApiGen