From ce2f670228a12dadf513b1068afbb75d815736ef Mon Sep 17 00:00:00 2001
From: Tilghman Lesher <tilghman@meg.abyt.es>
Date: Wed, 5 Dec 2007 16:46:47 +0000
Subject: [PATCH] Change cdr_manager to use a "CDR" level, rather than the
 (overcrowded) "call" level. (Closes issue #11015)

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@91173 65c4cc65-6c06-0410-ace0-fbb531ad65f3
---
 CHANGES                     | 2 ++
 UPGRADE.txt                 | 4 ++++
 cdr/cdr_manager.c           | 2 +-
 configs/manager.conf.sample | 4 ++--
 include/asterisk/manager.h  | 2 ++
 main/manager.c              | 1 +
 6 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/CHANGES b/CHANGES
index 34ca72d21c..3380c62ccb 100644
--- a/CHANGES
+++ b/CHANGES
@@ -23,6 +23,8 @@ AMI - The manager (TCP/TLS/HTTP)
   * Added a "ListAllVoicemailUsers" action that allows you to get a list of all
      the voicemail users setup.
   * Added 'DBDel' and 'DBDelTree' manager commands.
+  * cdr_manager now reports events via the "cdr" level, separating it from
+     the very verbose "call" level.
 
 Dialplan functions
 ------------------
diff --git a/UPGRADE.txt b/UPGRADE.txt
index 82374eb59f..06828c6834 100644
--- a/UPGRADE.txt
+++ b/UPGRADE.txt
@@ -146,3 +146,7 @@ Manager:
 * The IAXpeers command output has been changed to more closely resemble the
   output of the SIPpeers command.
 
+* cdr_manager now reports at the "cdr" level, not at "call"  You may need to
+   change your manager.conf to add the level to existing AMI users, if they
+   want to see the CDR events generated.
+
diff --git a/cdr/cdr_manager.c b/cdr/cdr_manager.c
index b6f5deb6a4..8b2ab215d4 100644
--- a/cdr/cdr_manager.c
+++ b/cdr/cdr_manager.c
@@ -146,7 +146,7 @@ static int manager_log(struct ast_cdr *cdr)
 		pbx_substitute_variables_helper(&dummy, customfields->str, buf, sizeof(buf) - 1);
 	}
 
-	manager_event(EVENT_FLAG_CALL, "Cdr",
+	manager_event(EVENT_FLAG_CDR, "Cdr",
 	    "AccountCode: %s\r\n"
 	    "Source: %s\r\n"
 	    "Destination: %s\r\n"
diff --git a/configs/manager.conf.sample b/configs/manager.conf.sample
index dceec13788..b4d6a0909e 100644
--- a/configs/manager.conf.sample
+++ b/configs/manager.conf.sample
@@ -71,5 +71,5 @@ bindaddr = 0.0.0.0
 ;displayconnects = yes	; Display on CLI user login/logoff
 ;
 ; Authorization for various classes 
-;read = system,call,log,verbose,command,agent,user,config,dtmf,reporting
-;write = system,call,log,verbose,command,agent,user,config,dtmf,reporting
+;read = system,call,log,verbose,command,agent,user,config,dtmf,reporting,cdr
+;write = system,call,log,verbose,command,agent,user,config,dtmf,reporting,cdr
diff --git a/include/asterisk/manager.h b/include/asterisk/manager.h
index 79a1998d09..a57e890fd4 100644
--- a/include/asterisk/manager.h
+++ b/include/asterisk/manager.h
@@ -63,6 +63,8 @@
 #define EVENT_FLAG_CONFIG		(1 << 7) /* Ability to modify configurations */
 #define EVENT_FLAG_DTMF  		(1 << 8) /* Ability to read DTMF events */
 #define EVENT_FLAG_REPORTING		(1 << 9) /* Reporting events such as rtcp sent */
+#define EVENT_FLAG_CDR			(1 << 10) /* CDR events */
+
 /* Export manager structures */
 #define AST_MAX_MANHEADERS 128
 
diff --git a/main/manager.c b/main/manager.c
index 6b3bf700b7..4c2a340b7d 100644
--- a/main/manager.c
+++ b/main/manager.c
@@ -309,6 +309,7 @@ static struct permalias {
 	{ EVENT_FLAG_CONFIG, "config" },
 	{ EVENT_FLAG_DTMF, "dtmf" },
 	{ EVENT_FLAG_REPORTING, "reporting" },
+	{ EVENT_FLAG_CDR, "cdr" },
 	{ -1, "all" },
 	{ 0, "none" },
 };
-- 
GitLab