Sha256: 1fa612b87e364867875b140d50311fc778c0f1d6dd12d7ffff2ce690a421f6db

Contents?: true

Size: 747 Bytes

Versions: 19

Compression:

Stored size: 747 Bytes

Contents

require 'logger'

module NetSuite
  class XmlLogger < ::Logger

    def format_message(severity, timestamp, progname, msg)
      if msg.match('<?xml') && !(msg.match('SOAPAction'))
        xp(msg)
      else
        "#{msg}\n"
      end
    end

    def xp(xml_text)
      xsl = <<-XSL
        <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:output method="xml" encoding="UTF-8" indent="yes"/>
        <xsl:strip-space elements="*"/>
        <xsl:template match="/">
          <xsl:copy-of select="."/>
        </xsl:template>
        </xsl:stylesheet>
      XSL
      doc  = Nokogiri::XML(xml_text)
      xslt = Nokogiri::XSLT(xsl)
      out  = xslt.transform(doc)
      out.to_xml
    end

  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
netsuite-0.0.50 lib/netsuite/xml_logger.rb
netsuite-0.0.49 lib/netsuite/xml_logger.rb
netsuite-0.0.48 lib/netsuite/xml_logger.rb
netsuite-0.0.47 lib/netsuite/xml_logger.rb
netsuite-0.0.45 lib/netsuite/xml_logger.rb
netsuite-0.0.44 lib/netsuite/xml_logger.rb
netsuite-0.0.43 lib/netsuite/xml_logger.rb
netsuite-0.0.42 lib/netsuite/xml_logger.rb
netsuite-0.0.41 lib/netsuite/xml_logger.rb
netsuite-0.0.40 lib/netsuite/xml_logger.rb
netsuite-0.0.39 lib/netsuite/xml_logger.rb
netsuite-0.0.38 lib/netsuite/xml_logger.rb
netsuite-0.0.37 lib/netsuite/xml_logger.rb
netsuite-0.0.36 lib/netsuite/xml_logger.rb
netsuite-0.0.35 lib/netsuite/xml_logger.rb
netsuite-0.0.34 lib/netsuite/xml_logger.rb
netsuite-0.0.33 lib/netsuite/xml_logger.rb
netsuite-0.0.32 lib/netsuite/xml_logger.rb
netsuite-0.0.31 lib/netsuite/xml_logger.rb