diff options
author | dklawren <dklawren@users.noreply.github.com> | 2017-11-29 19:54:22 +0100 |
---|---|---|
committer | Dylan William Hardison <dylan@hardison.net> | 2017-11-29 19:54:22 +0100 |
commit | 7da8e374e0c96e10077690935e829b0c04fc82f4 (patch) | |
tree | 44a92ccdee16c45badd35e9c986294fd40beec12 /extensions/PhabBugz/lib/Logger.pm | |
parent | 64ce7cb12deee5f394a869d9ec6b5e46cd2679f0 (diff) | |
download | bugzilla-7da8e374e0c96e10077690935e829b0c04fc82f4.tar.gz bugzilla-7da8e374e0c96e10077690935e829b0c04fc82f4.tar.xz |
Bug 1409957 - Create polling daemon to query Phabricator for recent transcations and update bug data according to revision changes
Diffstat (limited to 'extensions/PhabBugz/lib/Logger.pm')
-rw-r--r-- | extensions/PhabBugz/lib/Logger.pm | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/extensions/PhabBugz/lib/Logger.pm b/extensions/PhabBugz/lib/Logger.pm new file mode 100644 index 000000000..3127b66db --- /dev/null +++ b/extensions/PhabBugz/lib/Logger.pm @@ -0,0 +1,37 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# This Source Code Form is "Incompatible With Secondary Licenses", as +# defined by the Mozilla Public License, v. 2.0. + +package Bugzilla::Extension::PhabBugz::Logger; + +use 5.10.1; + +use Moo; + +use Bugzilla::Extension::PhabBugz::Constants; + +has 'debugging' => ( is => 'ro' ); + +sub info { shift->_log_it('INFO', @_) } +sub error { shift->_log_it('ERROR', @_) } +sub debug { shift->_log_it('DEBUG', @_) } + +sub _log_it { + my ($self, $method, $message) = @_; + + return if $method eq 'DEBUG' && !$self->debugging; + chomp $message; + if ($ENV{MOD_PERL}) { + require Apache2::Log; + Apache2::ServerRec::warn("FEED $method: $message"); + } elsif ($ENV{SCRIPT_FILENAME}) { + print STDERR "FEED $method: $message\n"; + } else { + print STDERR '[' . localtime(time) ."] $method: $message\n"; + } +} + +1; |