Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F5977506
GenericTranslateJob.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
GenericTranslateJob.php
View Options
<?php
declare
(
strict_types
=
1
);
namespace
MediaWiki\Extension\Translate\Jobs
;
use
Job
;
use
MediaWiki\Extension\Translate\LogNames
;
use
MediaWiki\Logger\LoggerFactory
;
use
Psr\Log\LoggerInterface
;
/**
* Generic Job class extended by other jobs. Provides logging functionality.
* @author Abijeet Patro
* @license GPL-2.0-or-later
* @since 2019.08
*/
abstract
class
GenericTranslateJob
extends
Job
{
private
LoggerInterface
$logger
;
/**
* Returns a logger instance with the channel name. Can have only a single
* channel per job, so once instantiated, the same instance is returned.
*/
private
function
getLogger
():
LoggerInterface
{
$this
->
logger
??=
LoggerFactory
::
getInstance
(
LogNames
::
JOBS
);
return
$this
->
logger
;
}
/** @phan-return array{0:string,1:array} */
private
function
formatLogEntry
(
string
$msg
,
array
$context
=
[]
):
array
{
$prefix
=
$this
->
getType
();
if
(
$this
->
title
!==
null
)
{
$prefix
.=
' [{job_title}]'
;
$context
[
'job_title'
]
=
$this
->
title
->
getPrefixedText
();
}
return
[
"$prefix: $msg"
,
$context
];
}
protected
function
logDebug
(
string
$msg
,
array
$context
=
[]
):
void
{
[
$msg
,
$context
]
=
$this
->
formatLogEntry
(
$msg
,
$context
);
$this
->
getLogger
()->
debug
(
$msg
,
$context
);
}
protected
function
logInfo
(
string
$msg
,
array
$context
=
[]
):
void
{
[
$msg
,
$context
]
=
$this
->
formatLogEntry
(
$msg
,
$context
);
$this
->
getLogger
()->
info
(
$msg
,
$context
);
}
protected
function
logNotice
(
string
$msg
,
array
$context
=
[]
):
void
{
[
$msg
,
$context
]
=
$this
->
formatLogEntry
(
$msg
,
$context
);
$this
->
getLogger
()->
notice
(
$msg
,
$context
);
}
protected
function
logWarning
(
string
$msg
,
array
$context
=
[]
):
void
{
[
$msg
,
$context
]
=
$this
->
formatLogEntry
(
$msg
,
$context
);
$this
->
getLogger
()->
warning
(
$msg
,
$context
);
}
protected
function
logError
(
string
$msg
,
array
$context
=
[]
):
void
{
[
$msg
,
$context
]
=
$this
->
formatLogEntry
(
$msg
,
$context
);
$this
->
getLogger
()->
error
(
$msg
,
$context
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, Oct 3, 19:57 (3 d, 2 h ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
c7/86/65c3c656405b8e1d391e6149388b
Default Alt Text
GenericTranslateJob.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment