Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
TelegramBot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
TelegramBot
Commits
c50a4ce6
Commit
c50a4ce6
authored
Sep 21, 2015
by
MBoretto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Introducing Exception logging
parent
cb1d270c
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
18 additions
and
8 deletions
+18
-8
README.md
README.md
+5
-5
example-getUpdatesCLI.php
example-getUpdatesCLI.php
+1
-1
example-hook.php
example-hook.php
+1
-1
example-set.php
example-set.php
+1
-1
TelegramException.php
src/Exception/TelegramException.php
+10
-0
No files found.
README.md
View file @
c50a4ce6
...
...
@@ -143,7 +143,7 @@ try {
echo
$result
->
getDescription
();
}
}
catch
(
Longman\TelegramBot\Exception\TelegramException
$e
)
{
echo
$e
->
getMessage
()
;
echo
$e
;
}
...
...
@@ -168,7 +168,7 @@ try {
$telegram
->
handle
();
}
catch
(
Longman\TelegramBot\Exception\TelegramException
$e
)
{
// log telegram errors
// echo $e
->getMessage()
;
// echo $e;
}
```
## getUpdate installation NEW!
...
...
@@ -193,7 +193,7 @@ try {
$telegram
->
handleGetUpdates
();
}
catch
(
Longman\TelegramBot\Exception\TelegramException
$e
)
{
// log telegram errors
echo
$e
->
getMessage
()
;
echo
$e
;
}
...
...
@@ -291,9 +291,9 @@ You can also log incoming messages on a text file, set this option with the meth
$telegram
->
setLogRequests
(
true
);
$telegram
->
setLogPath
(
$BOT_NAME
.
'.log'
);
```
-----
Thrown Exception are stored in TelegramException.log file.
-----
This code is available on
[
Github
](
https://github.com/akalongman/php-telegram-bot
)
. Pull
requests are welcome.
...
...
example-getUpdatesCLI.php
View file @
c50a4ce6
...
...
@@ -31,5 +31,5 @@ try {
$telegram
->
handleGetUpdates
();
}
catch
(
Longman\TelegramBot\Exception\TelegramException
$e
)
{
// log telegram errors
echo
$e
->
getMessage
()
;
echo
$e
;
}
example-hook.php
View file @
c50a4ce6
...
...
@@ -27,5 +27,5 @@ try {
$telegram
->
handle
();
}
catch
(
Longman\TelegramBot\Exception\TelegramException
$e
)
{
// log telegram errors
// echo $e
->getMessage()
;
// echo $e;
}
example-set.php
View file @
c50a4ce6
...
...
@@ -14,5 +14,5 @@ try {
echo
$result
->
getDescription
();
}
}
catch
(
Longman\TelegramBot\Exception\TelegramException
$e
)
{
echo
$e
->
getMessage
()
;
echo
$e
;
}
src/Exception/TelegramException.php
View file @
c50a4ce6
...
...
@@ -11,4 +11,14 @@ namespace Longman\TelegramBot\Exception;
class
TelegramException
extends
\Exception
{
public
function
__construct
(
$message
,
$code
=
0
)
{
parent
::
__construct
(
$message
,
$code
);
$path
=
'TelegramException.log'
;
$status
=
file_put_contents
(
$path
,
date
(
'Y-m-d H:i:s'
,
time
())
.
' '
.
self
::
__toString
()
.
"
\n
"
,
FILE_APPEND
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment