33namespace BNETDocs \Libraries ;
44
55use \BNETDocs \Libraries \Exceptions \QueryException ;
6+ use \BNETDocs \Libraries \User ;
67use \CarlBennett \MVC \Libraries \Common ;
78use \CarlBennett \MVC \Libraries \DatabaseDriver ;
89use \CarlBennett \MVC \Libraries \Logger as LoggerMVCLib ;
10+ use \Exception ;
911use \InvalidArgumentException ;
1012use \PDO ;
1113use \PDOException ;
1517class Logger extends LoggerMVCLib {
1618
1719 protected static $ event_types = null ;
20+ protected static $ identified_as = null ;
1821 protected static $ rollbar_available = false ;
1922
23+ public static function getIdentity () {
24+ return self ::$ identified_as ;
25+ }
26+
27+ public static function getIdentityAsRollbar () {
28+ $ user = self ::getIdentity ();
29+ return [
30+ 'email ' => $ user ->getEmail (),
31+ 'id ' => $ user ->getId (),
32+ 'username ' => $ user ->getUsername (),
33+ ];
34+ }
35+
2036 public static function getTimingHeader ($ tags = true ) {
2137 $ buffer = parent ::getTimingHeader ($ tags );
2238 if (self ::$ rollbar_available ) {
@@ -27,6 +43,10 @@ public static function getTimingHeader($tags = true) {
2743 return $ buffer ;
2844 }
2945
46+ public static function identifyAs (User $ user ) {
47+ self ::$ identified_as = $ user ;
48+ }
49+
3050 public static function initialize () {
3151 parent ::initialize ();
3252 if (Common::$ config ->rollbar ->access_token_server ) {
@@ -40,6 +60,7 @@ public static function initialize() {
4060 [
4161 'access_token ' => Common::$ config ->rollbar ->access_token_server ,
4262 'environment ' => Common::$ config ->rollbar ->environment ,
63+ 'person_fn ' => 'Logger::getIdentityAsRollbar ' ,
4364 ],
4465 $ rollbar_handle_exceptions ,
4566 $ rollbar_handle_errors ,
0 commit comments