#!/bin/sh

##############################################################################
# If not stated otherwise in this file or this component's LICENSE file the
# following copyright and licenses apply:
#
# Copyright 2020 RDK Management
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
##############################################################################


. /etc/include.properties
. /etc/device.properties

logRotateEnable=true
logRotateFlag=1
logFileBase=$LOG_PATH
logRotateCheckInterval=60
logRotateForceInterval=86400
logRotateGenericCount=3
logRotateWPEFrameworkCount=3
logRotateResidentAppCount=1
logRotateGenericSize=1572864

applnLog=$LOG_PATH/applications.log
riLog=$LOG_PATH/ocapri_log.txt
podLog=$LOG_PATH/pod_log.txt
rmfLog=$LOG_PATH/rmfstr_log.txt
vodLog=$LOG_PATH/vodclient_log.txt
pumalog=$LOG_PATH/messages-puma.txt
ecmLog=$LOG_PATH/messages-ecm.txt
sysLog=$LOG_PATH/messages.txt
mfrLog=$LOG_PATH/mfrlib_log.txt
fusionDaleLog=$LOG_PATH/fusiondale_log.txt
mainMONLog=$LOG_PATH/mpeos-mainMON.txt
receiverMONLog=$LOG_PATH/ReceiverMON.txt
receiverLog=$LOG_PATH/receiver.log
ttsLog=$LOG_PATH/tts_engine.log
uimngrFile=$LOG_PATH/uimgr_log.txt
storagemgrLog=$LOG_PATH/storagemgr.log
ctrlmFile=$LOG_PATH/ctrlm_log.txt
fdsLog=$LOG_PATH/fds.log
xDiscoveryLog=$LOG_PATH/xdiscovery.log
xDiscoveryLogList=$LOG_PATH/xdiscoverylist.log
trmLog=$LOG_PATH/trm.log
trmMgrLog=$LOG_PATH/trmmgr.log
runXreLog=$LOG_PATH/runXRE_log.txt
lighttpdErrorLog=$LOG_PATH/lighttpd.error.log
lighttpdAccessLog=$LOG_PATH/lighttpd.access.log
dcmLog=$LOG_PATH/dcmscript.log
mocaStatusLog=$LOG_PATH/mocaStatus.log
mocaDriverLog=$LOG_PATH/moca-driver.log
mocaServiceLog=$LOG_PATH/mocaService.log
xDeviceLog=$LOG_PATH/xdevice.log
snmp2jsonLog=$LOG_PATH/snmp2json.log
socProvLog=$LOG_PATH/socprov.log
socProvCryptoLog=$LOG_PATH/socprov-crypto.log
vlThreadLog=$LOG_PATH/vlthreadanalyzer_log.txt
wifiTelemetryLog=$LOG_PATH/wifi_telemetry.log
tr69AgentLog=$LOG_PATH/tr69agent.log
tr69AgentHttpLog=$LOG_PATH/tr69agent_HTTP.log
tr69AgentSoapLog=$LOG_PATH/tr69agent_SoapDebug.log
decoderStatusLog=$LOG_PATH/procStatus.log
cecLog=$LOG_PATH/cec_log.txt
netsrvLog=$LOG_PATH/netsrvmgr.log
snmpdLog=$LOG_PATH/snmpd.log
fogLog=$LOG_PATH/fog.log
dibblerLog=$LOG_PATH/dibbler.log
diskStatusLog=$LOG_PATH/disk_cleanup.log
mountLog=$LOG_PATH/mount_log.txt
systemLog=$LOG_PATH/system.log
upstreamStatsLog=$LOG_PATH/upstream_stats.log
xiRecoveryLog=$LOG_PATH/discoverV4Client.log
ConnectionStatusLog=$LOG_PATH/ConnectionStats.txt
bluetoothLog=$LOG_PATH/btmgrlog.txt
rbiDaemonLog=$LOG_PATH/rbiDaemon.log
rfcLog=$LOG_PATH/rfcscript.log
ntpLog=$LOG_PATH/ntp.log
dnsmasqLog=$LOG_PATH/dnsmasq.log
tlsLog=$LOG_PATH/tlsError.log
btrLeAppMgrLog=$LOG_PATH/btrLeAppMgr.log
pingTelemetryLog=$LOG_PATH/ping_telemetry.log
nlmonLog=$LOG_PATH/nlmon.log
hwselfLog=$LOG_PATH/hwselftest.log
cgrpmemoryLog=$LOG_PATH/cgrpmemory.log
cgrmemorytestLog=$LOG_PATH/cgrmemorytest.log
wpeframeworkLog=$LOG_PATH/wpeframework.log
residentAppLog=$LOG_PATH/residentApp.log
servicenumberLog=$LOG_PATH/servicenumber.log
appsRdmLog=$LOG_PATH/rdm_status.log
rebootReasonLog=$LOG_PATH/rebootreason.log
dropbearLog=$LOG_PATH/dropbear.log
parodusLog=$LOG_PATH/parodus.log
appmanagerLog=$LOG_PATH/appmanager.log
xdialLog=$LOG_PATH/xdial.log
dibblerclientLog=$LOG_PATH/dibbler-client.log
ecfsLog=$LOG_PATH/ecfs.txt
iptablesLog=$LOG_PATH/iptables.log
perfmonstatusLog=$LOG_PATH/perfmonstatus.log
rdkmilestonesLog=$LOG_PATH/rdk_milestones.log
stunnelLog=$LOG_PATH/stunnel.log
tr69HostIfLog=$LOG_PATH/tr69hostif.log
hdcpLog=$LOG_PATH/hdcp.log
threadLog=$LOG_PATH/thread.log
adobeCleanupLog=$LOG_PATH/cleanAdobe.log
bootUpLog=$LOG_PATH/bootlog
LastUrlLog=$LOG_PATH/last_url.txt
CrashedUrlLog=$LOG_PATH/crashed_url.txt
cpuprocanalyzerLog=$LOG_PATH/cpuprocanalyzer.log
namedLog=$LOG_PATH/named.log
dnsqueryLog=$LOG_PATH/dnsquery.log
rtroutedLog=$LOG_PATH/rtrouted.log
bluezLog=$LOG_PATH/bluez.log
rtkfwlog=$LOG_PATH/rtk_fw.log
rtkafwlicensechecklog=$LOG_PATH/rtk_afw_license_check.log

if [ "$DOBBY_ENABLED" == "true" ];then
        dobbyLog=$LOG_PATH/dobby.log
fi

if [ "x$SYSLOG_NG_ENABLED" == "xtrue" ];then
    syslogFallbackLog=$LOG_PATH/syslog_fallback.log
    #syslogFallbackLogRotateCount=2
    #syslogFallbackLogRotateSize=512000
fi

if [ "$CONTAINER_SUPPORT" == "true" ];then
    lxcxreLog=$LOG_PATH/xre.log
    lxcxreAppLog=$LOG_PATH/xre-applications.log
fi
hddStatusLog=$LOG_PATH/diskinfo.log

if [ "$WIFI_SUPPORT" == "true" ];then
    wpaSupplicantLog=$LOG_PATH/wpa_supplicant.log
    dhcpWifiLog=$LOG_PATH/dhcp-wifi.log
fi
if [ "$SOC" = "BRCM" ];then
     nxSvrLog="nxserver.log"
     nxSvrLogRotateCount=1
     nxSvrLogRotateSize=200000
     if [ "$PROC_STATUS_LOG_SUPPORT" = "true" ];then
         procStatusLog=$LOG_PATH/proc-status-logger.log
         procLogRotateCount=2
         procLogRotateSize=256000
    fi
fi

if [ "$SOC" = "AMLOGIC" ];then
        AudioServerLog=$LOG_PATH/audioserver.log
        TvServerLog=$LOG_PATH/tvservice.log
	PqserverLog=$LOG_PATH/pqserver.log
        logRotateAmlGenericCount=3
        logRotateWPEFrameworkCount=6
        logRotateAudioServerCount=6
        logRotateAmlGenericSize=200000
	logRotateAudioServerSize=10485760
	logRotatePqserverSize=1572864
fi

if [ "$SOC" = "RTK" ];then
        realtekDmesgKernelLog=$LOG_PATH/dmesg-ramoops-0.log
        realtekConsoleKernelLog=$LOG_PATH/console-ramoops-0.log
        realtekServiceLog=$LOG_PATH/rtk_service.log
fi

if [ "$DEVICE_NAME" = "PLATCO" ]; then
        factoryCommsLog=$LOG_PATH/factoryComms.log
fi

if [ "$MEDIARITE" == "true" ];then
        MediaRiteLog=$LOG_PATH/mediarite.log
        logRotateMediaRiteGenericCount=2
        logRotateMediaRiteGenericSize=10485760
fi


if [ "$MEMORY_LIMITATION_FLAG" != "true" ]; then
     logRotateCount=25
     # ri, uimgr, ctrlm
     riLogRotateCount=25
     uimngrRotateCount=25
     ctrlmRotateCount=25
    # pod, rmf, vod, trm
     trmRotateCount=10
     rmfLogRotateCount=10
     vodLogRotateCount=10
     podLogRotateCount=10

     # ecm, mpeos-mainMON,receiverMON
     pumalogRotatCount=5
     mainMONLogRotatCount=5
     receiverMONLogRotatCount=5
     receiverLogRotatCount=30
     ttsLogRotatCount=5
     diskStatusLogRotateCount=5
     mountLogRotateCount=5
     systemLogRotateCount=5
     ecmLogRotatCount=5
     runXreLogRotatCount=3
     fusionDaleLogRotateCount=0
     #messages.txt
     sysLogRotatCount=3
     ntpRotateCount=3
     # fds
     fdsRotateCount=2
     #dcm, xdicovery, xdiscoveryList
     xdisRotateCount=1
     dcmLogRotateCount=1
     lighttpdRotateCount=1

     # ri, uimgr, msgs.txt, ctrlm
     riLogRotateSize=20971520
     uimngrRotateSize=20971520
     ctrlmRotateSize=20971520
     sysLogRotatSize=20971520
     ntpLogRotateSize=1572864
     pumalogRotatSize=20971520
     ecmLogRotatSize=20971520
     runXreLogRotatSize=512000
     fusionDaleLogRotateSize=0
     # pod, rmf, vod, ecm
     rmfLogRotateSize=10485760
     podLogRotateSize=10485760
     vodLogRotateSize=10485760
     #mpeos-mainMON.txt,ReceiverMON.txt, xdiscovery, xdiscoveryList 
     xdisRotateSize=1048576
     mainMONLogRotatSize=1048576
     receiverMONLogRotatSize=1048576
     receiverLogRotatSize=10485760
     ttsLogRotatSize=1572864
     diskStatusLogRotateSize=10485760
     mountLogRotateSize=10485760
     systemLogRotateSize=10485760
     lighttpdRotateSize=1048576
     # fds
     fdsRotateSize=16777216
     # trm, dcm
     trmRotateSize=1572864
     dcmLogRotateSize=1572864
     # moca status
     mocaStatRotateCount=4
     mocaStatRotateSize=1048576
     # moca driver
     mocaDriverRotateCount=4
     mocaDriverRotateSize=1048576
     # moca service 
     mocaServiceRotateCount=4
     mocaServiceRotateSize=1048576
     # mfr
     mfrLogRotateCount=5
     mfrLogRotateSize=1048576
     # xdevice
     xDeviceRotateCount=3
     xDeviceRotateSize=512000
     applnLogRotateCount=5
     applnLogRotateSize=20971520
     # socprov
     socProvRotateCount=1
     socProvRotateSize=512000
     vlThreadRotateCount=4
     vlThreadRotateSize=1572864
     bluetoothLogRotateCount=5
     bluetoothLogRotateSize=512000
     cecLogRotateCount=1
     cecLogRotateSize=5242880
     bluetoothLeAppMgrLogRotateCount=5
     bluetoothLeAppMgrLogRotateSize=512000
     bluezLogRotateCount=5
     bluezLogRotateSize=512000
else
     logRotateCount=5
     # ri
     riLogRotateCount=5
     #fusiondale_log.txt
     fusionDaleLogRotateCount=3
     # ECM .txt, messages.txt, mpeos-mainMON.txt, ReceiverMON.txt,
     # runXRE_log.txt, fds
     fdsRotateCount=2 
     trmRotateCount=2
     ecmLogRotatCount=2
     sysLogRotatCount=2
     ntpRotateCount=2
     runXreLogRotatCount=2
     mainMONLogRotatCount=2
     receiverMONLogRotatCount=2
     receiverLogRotatCount=3
     ttsLogRotatCount=3
     # uimgr, http access, http error, dcm, xdiscovery, xdiscoveryList, ctrlm
     decoderStatusLogRotateCount=1
     xdisRotateCount=1
     dcmLogRotateCount=1
     uimngrRotateCount=1
     ctrlmRotateCount=3
     lighttpdRotateCount=1
     lighttpdRotateCount=1
     diskStatusLogRotateCount=1
     mountLogRotateCount=1
     systemLogRotateCount=1

     pumalogRotatCount=0
     podLogRotateCount=0
     vodLogRotateCount=1
     rmfLogRotateCount=3
     # ri
     riLogRotateSize=1572864
     # runXreLog, xdiscovery, xdiscoveryList, ECM.txt
     xdisRotateSize=512000
     ecmLogRotatSize=1048576
     runXreLogRotatSize=512000
   
     # fusionDale, mainMON, receiverMON, messages.txt, fds
     fdsRotateSize=409600
     sysLogRotatSize=409600    
     ntpLogRotateSize=409600
     mainMONLogRotatSize=409600
     receiverMONLogRotatSize=409600
     receiverLogRotatSize=1572864
     ttsLogRotatSize=1572864
     decoderStatusLogRotateSize=153600
     fusionDaleLogRotateSize=409600

     # uimgr, dcm, ctrlm,trm
     uimngrRotateSize=512000
     ctrlmRotateSize=512000
     dcmLogRotateSize=512000
     trmRotateSize=512000
     # http logs
     lighttpdRotateSize=204800

     pumalogRotatSize=0
     rmfLogRotateSize=1572864
     vodLogRotateSize=409600
     # moca
     mocaStatRotateCount=3
     mocaStatRotateSize=512000
     # moca driver
     mocaDriverRotateCount=3
     mocaDriverRotateSize=512000
     # moca service 
     mocaServiceRotateCount=3
     mocaServiceRotateSize=512000
     # mfrlib
     mfrLogRotateCount=1
     mfrLogRotateSize=512000
     # xDevice
     xDeviceRotateCount=3
     xDeviceRotateSize=512000
     applnLogRotateCount=2
     applnLogRotateSize=512000
     # socprov
     socProvRotateCount=1
     socProvRotateSize=262144
     vlThreadRotateCount=1
     vlThreadRotateSize=262144
    
     wifiTelemetryLogRotateCount=2
     wifiTelemetryLogRotateSize=512000
     tr69AgentHttpLogRotateCount=2
     tr69AgentSoapLogRotateCount=2
     tr69AgentHttpLogRotateSize=204800
     tr69AgentSoapLogRotateSize=204800
     diskStatusLogRotateSize=204800
     mountLogRotateSize=204800
     systemLogRotateSize=512800
     bluetoothLogRotateCount=2
     bluetoothLogRotateSize=250000
     cecLogRotateCount=1
     cecLogRotateSize=128000
     bluetoothLeAppMgrLogRotateSize=250000
     bluetoothLeAppMgrLogRotateCount=2
     bluezLogRotateCount=2
     bluezLogRotateSize=250000
fi

# storagemgr
storagemgrLogRotateCount=1
storagemgrLogRotateSize=524288

#parodus Log
parodusLogRotateSize=128000

#appmanager logging
appmanagerLogRotateCount=1
appmanagerLogRotateSize=1572864

#cpuprocanalyzer Log
cpuprocanalyzerLogRotateCount=3
cpuprocanalyzerLogRotateSize=128000

#named and dnsquerylog
namedLogRotateCount=3
namedLogRotateSize=128000

dnsqueryLogRotateCount=3
dnsqueryLogRotateSize=128000

# For sky products only
if [ "$SKY_EPG_SUPPORT" == "true" ] || [ "$SKY_SERVICE_LOGGING" == "true" ]; then
   skyMessagesLogRotateCount=4
   skyMessagesLogRotateSize=10485760
   skyMessagesLog=$LOG_PATH/sky-messages.log
fi

# lxc
if [ "$CONTAINER_SUPPORT" == "true" ];then
    lxcxreLogRotateSize=51200
    lxcxreAppLogRotateSize=51200
fi

if [ "$DEVICE_TYPE" ==  "XHC1" ];then
        coreDumpLog=$LOG_PATH/core_log.txt
        logRotateGenericCount=3
        logRotateGenericSize=128000

        applnLogRotateCount=3
        applnLogRotateSize=256000
	
	streamsrvLog=$LOG_PATH/stream_server_log.txt
        streamsrvLogRotateSize=128000
	
	stunnelHttpsLog=$LOG_PATH/stunnel_https_log.txt
	stunnelHttpsLogRotateSize=64000
        
	upnpLog=$LOG_PATH/upnp_log.txt
	upnpLogRotateSize=128000
	
	upnpigdLog=$LOG_PATH/upnpigd_log.txt
	upnpigdLogRotateSize=128000
	
	cgiLog=$LOG_PATH/cgi_log.txt
        cgiLogRotateSize=64000

	systemLog=$LOG_PATH/system_log.txt
        systemLogRotateSize=128000

	eventLog=$LOG_PATH/event_log.txt
        eventLogRotateSize=128000

	xw3MonitorLog=oem_log.txt
        xw3MonitorLogRotateSize=128000

	sensorDLog=sensor_daemon_log.txt
        sensorDLogRotateSize=64000

        webpaLog=$LOG_PATH/webpa_log.txt
        webpaLogRotateSize=128000

	userLog=$LOG_PATH/user_log.txt
        userLogRotateSize=64000
       
        webrtcStreamingLog=$LOG_PATH/webrtc_streaming_log.txt
        webrtcStreamingLogRotateSize=512000
 
        cvrPollLog=$LOG_PATH/cvrpoll_log.txt
        cvrPollLogRotateSize=512000

        watchDogLog=$LOG_PATH/watchDog_log.txt
        watchDogLogRotateCount=2
        watchDogLogRotateSize=64000

        xwSystemLog=$LOG_PATH/xwSystemInfo.log
        xwSystemLogRotateCount=3
        xwSystemLogRotateSize=64000

        thumbnailUploadLog=$LOG_PATH/thumbnail_log.txt
        thumbnailUploadLogRotateSize=512000

        audioAnalyticsLog=$LOG_PATH/xcvaa_log.txt
        audioAnalyticsLogRotateCount=3
        audioAnalyticsLogRotateSize=512000

        smartThumbnailLog=$LOG_PATH/smart_thumbnail_log.txt
        smartThumbnailLogRotateSize=512000

	metricsLog=$LOG_PATH/dmesg_log.txt
        metricsLogRotateSize=256000

        wifiLog=$LOG_PATH/wifi_log.txt
        wifiLogRotateSize=64000

	netsrvmgrLogRotateSize=512000

        rfcLog=$LOG_PATH/rfcscript.log
        rfcLogRotateSize=64000

        sysLogRotatCount=2
        sysLogRotatSize=128000

	xvisionLog=$LOG_PATH/xvision_log.txt
        xvisionLogRotateSize=512000

        evoLog=$LOG_PATH/evo_log.txt
        evoLogRotateSize=512000

	overlayLog=$LOG_PATH/overlay_log.txt
	overlayLogRotateSize=64000

	iavencoderLog=$LOG_PATH/iav_encoder_log.txt
	iavencoderLogRotateCount=3
	iavencoderLogRotateSize=64000

        smartrcLog=$LOG_PATH/smartrc_log.txt
        smartrcLogRotateCount=3
        smartrcLogRotateSize=256000

	compatiblexwLog=$LOG_PATH/compatible_xw_log.txt
	compatiblexwLogRotateSize=64000

	ledmgrLog=$LOG_PATH/ledmgr_log.txt
	ledmgrLogRotateSize=128000

	xwconfigLog=$LOG_PATH/xwconfig_log.txt
	xwconfigLogRotateSize=64000

        xwconsoleLog=$LOG_PATH/xwconsole_log.txt
        xwconsoleLogRotateSize=64000

	wirelessdriverLog=$LOG_PATH/wirelessdriver_log.txt
        wirelessdriverLogRotateCount=5
        wirelessdriverLogRotateSize=64000

        prvnmgrLog=$LOG_PATH/prvnmgr_log.txt
	prvnmgrLogRotateSize=128000
 
        batterymgrLog=$LOG_PATH/battery_log.txt
        batterymgrLogRotateSize=128000

        gpiobuttonLog=$LOG_PATH/gpio_push_button_log.txt
        gpiobuttonLogRotateSize=128000

        thermalControlLog=$LOG_PATH/thermal_control_log.txt
	thermalControlLogRotateCount=3
	thermalControlLogRotateSize=128000

        xwrebootInfoLog=$LOG_PATH/rebootInfo_log.txt
	xwrebootInfoLogRotateSize=64000

        libledgerLog=$LOG_PATH/libledger.log
	libledgerLogRotateSize=64000

        ntpLogRotateSize=128000

        xw3systeminfo=$LOG_PATH/xw3_last_system_info.log
        xw3systeminfoSize=64000

        accessmanagerLog=$LOG_PATH/accessmanager.log
        accessmanagerLogRotateSize=64000
fi
