[haiku-commits] haiku: hrev44867 - src/kits/locale

  • From: zooey@xxxxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Tue, 20 Nov 2012 19:43:48 +0100 (CET)

hrev44867 adds 1 changeset to branch 'master'
old head: 75384e609293eebaaf9c60dc5c2690bc6e95d74a
new head: 93b5e5614cab5777788dff6f6ecd7cbe00892fe0
overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=93b5e56+%5E75384e6

----------------------------------------------------------------------------

93b5e56: Adjust Locale Kit to no longer use syslog

                                    [ Oliver Tappe <zooey@xxxxxxxxxxxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev44867
Commit:      93b5e5614cab5777788dff6f6ecd7cbe00892fe0
URL:         http://cgit.haiku-os.org/haiku/commit/?id=93b5e56
Author:      Oliver Tappe <zooey@xxxxxxxxxxxxxxx>
Date:        Tue Nov 20 18:33:05 2012 UTC

----------------------------------------------------------------------------

5 files changed, 20 insertions(+), 142 deletions(-)
src/kits/locale/Catalog.cpp             |  2 -
src/kits/locale/DefaultCatalog.cpp      | 99 ++++-------------------------
src/kits/locale/InitLocaleKit.cpp       | 21 +-----
src/kits/locale/LocaleRoster.cpp        | 11 +---
src/kits/locale/MutableLocaleRoster.cpp | 29 +--------

----------------------------------------------------------------------------

diff --git a/src/kits/locale/Catalog.cpp b/src/kits/locale/Catalog.cpp
index f2ec81a..25c2104 100644
--- a/src/kits/locale/Catalog.cpp
+++ b/src/kits/locale/Catalog.cpp
@@ -6,8 +6,6 @@
 
 #include <Catalog.h>
 
-#include <syslog.h>
-
 #include <Application.h>
 #include <Autolock.h>
 #include <CatalogData.h>
diff --git a/src/kits/locale/DefaultCatalog.cpp 
b/src/kits/locale/DefaultCatalog.cpp
index 43a39d0..b56368f 100644
--- a/src/kits/locale/DefaultCatalog.cpp
+++ b/src/kits/locale/DefaultCatalog.cpp
@@ -10,7 +10,6 @@
 
 #include <memory>
 #include <new>
-#include <syslog.h>
 
 #include <AppFileInfo.h>
 #include <Application.h>
@@ -118,9 +117,6 @@ DefaultCatalog::DefaultCatalog(const entry_ref 
&catalogOwner, const char *langua
        }
 
        fInitCheck = status;
-       log_team(LOG_DEBUG,
-               "trying to load default-catalog(sig=%s, lang=%s) results in %s",
-               fSignature.String(), language, strerror(fInitCheck));
 }
 
 
@@ -134,9 +130,6 @@ DefaultCatalog::DefaultCatalog(entry_ref *appOrAddOnRef)
        HashMapCatalog("", "", 0)
 {
        fInitCheck = ReadFromResource(*appOrAddOnRef);
-       log_team(LOG_DEBUG,
-               "trying to load embedded catalog from resources results in %s",
-               strerror(fInitCheck));
 }
 
 
@@ -167,8 +160,6 @@ DefaultCatalog::SetSignature(const entry_ref &catalogOwner)
        BAppFileInfo objectInfo(&objectFile);
        char objectSignature[B_MIME_TYPE_LENGTH];
        if (objectInfo.GetSignature(objectSignature) != B_OK) {
-               log_team(LOG_ERR, "File %s has no mimesignature, so it can't 
use"
-                       " localization.", catalogOwner.name);
                fSignature = "";
                return;
        }
@@ -183,8 +174,6 @@ DefaultCatalog::SetSignature(const entry_ref &catalogOwner)
        else
                stripSignature ++;
 
-       log_team(LOG_DEBUG, "Image %s requested catalog with mimetype %s",
-               catalogOwner.name, stripSignature);
        fSignature = stripSignature;
 }
 
@@ -204,40 +193,25 @@ DefaultCatalog::ReadFromFile(const char *path)
 
        BFile catalogFile;
        status_t res = catalogFile.SetTo(path, B_READ_ONLY);
-       if (res != B_OK) {
-               log_team(LOG_DEBUG, "LocaleKit DefaultCatalog: no catalog at 
%s", path);
+       if (res != B_OK)
                return B_ENTRY_NOT_FOUND;
-       }
 
        fPath = path;
-       log_team(LOG_DEBUG, "LocaleKit DefaultCatalog: found catalog at %s", 
path);
 
        off_t sz = 0;
        res = catalogFile.GetSize(&sz);
        if (res != B_OK) {
-               log_team(LOG_ERR, "LocaleKit DefaultCatalog: couldn't get size 
for "
-                       "catalog-file %s", path);
                return res;
        }
 
        auto_ptr<char> buf(new(std::nothrow) char [sz]);
-       if (buf.get() == NULL) {
-               log_team(LOG_ERR, "LocaleKit DefaultCatalog: couldn't allocate 
array "
-                       "of %d chars", sz);
+       if (buf.get() == NULL)
                return B_NO_MEMORY;
-       }
        res = catalogFile.Read(buf.get(), sz);
-       if (res < B_OK) {
-               log_team(LOG_ERR, "LocaleKit DefaultCatalog: couldn't read from 
"
-                       "catalog-file %s", path);
+       if (res < B_OK)
                return res;
-       }
-       if (res < sz) {
-               log_team(LOG_ERR,
-                       "LocaleKit DefaultCatalog: only got %lu instead of %Lu 
bytes from "
-                       "catalog-file %s", res, sz, path);
+       if (res < sz)
                return res;
-       }
        BMemoryIO memIO(buf.get(), sz);
        res = Unflatten(&memIO);
 
@@ -260,43 +234,24 @@ DefaultCatalog::ReadFromAttribute(const entry_ref 
&appOrAddOnRef)
 {
        BNode node;
        status_t res = node.SetTo(&appOrAddOnRef);
-       if (res != B_OK) {
-               log_team(LOG_ERR,
-                       "couldn't find app or add-on (dev=%lu, dir=%Lu, 
name=%s)",
-                       appOrAddOnRef.device, appOrAddOnRef.directory,
-                       appOrAddOnRef.name);
+       if (res != B_OK)
                return B_ENTRY_NOT_FOUND;
-       }
-
-       log_team(LOG_DEBUG,
-               "looking for embedded catalog-attribute in app/add-on"
-               "(dev=%lu, dir=%Lu, name=%s)", appOrAddOnRef.device,
-               appOrAddOnRef.directory, appOrAddOnRef.name);
 
        attr_info attrInfo;
        res = node.GetAttrInfo(BLocaleRoster::kEmbeddedCatAttr, &attrInfo);
-       if (res != B_OK) {
-               log_team(LOG_DEBUG, "no embedded catalog found");
+       if (res != B_OK)
                return B_NAME_NOT_FOUND;
-       }
-       if (attrInfo.type != B_MESSAGE_TYPE) {
-               log_team(LOG_ERR, "attribute %s has incorrect type and is 
ignored!",
-                       BLocaleRoster::kEmbeddedCatAttr);
+       if (attrInfo.type != B_MESSAGE_TYPE)
                return B_BAD_TYPE;
-       }
 
        size_t size = attrInfo.size;
        auto_ptr<char> buf(new(std::nothrow) char [size]);
-       if (buf.get() == NULL) {
-               log_team(LOG_ERR, "couldn't allocate array of %d chars", size);
+       if (buf.get() == NULL)
                return B_NO_MEMORY;
-       }
        res = node.ReadAttr(BLocaleRoster::kEmbeddedCatAttr, B_MESSAGE_TYPE, 0,
                buf.get(), size);
-       if (res < (ssize_t)size) {
-               log_team(LOG_ERR, "unable to read embedded catalog from 
attribute");
+       if (res < (ssize_t)size)
                return res < B_OK ? res : B_BAD_DATA;
-       }
 
        BMemoryIO memIO(buf.get(), size);
        res = Unflatten(&memIO);
@@ -310,35 +265,20 @@ DefaultCatalog::ReadFromResource(const entry_ref 
&appOrAddOnRef)
 {
        BFile file;
        status_t res = file.SetTo(&appOrAddOnRef, B_READ_ONLY);
-       if (res != B_OK) {
-               log_team(LOG_ERR,
-                       "couldn't find app or add-on (dev=%lu, dir=%Lu, 
name=%s)",
-                       appOrAddOnRef.device, appOrAddOnRef.directory,
-                       appOrAddOnRef.name);
+       if (res != B_OK)
                return B_ENTRY_NOT_FOUND;
-       }
-
-       log_team(LOG_DEBUG,
-               "looking for embedded catalog-resource in app/add-on"
-               "(dev=%lu, dir=%Lu, name=%s)", appOrAddOnRef.device,
-               appOrAddOnRef.directory, appOrAddOnRef.name);
 
        BResources rsrc;
        res = rsrc.SetTo(&file);
-       if (res != B_OK) {
-               log_team(LOG_DEBUG, "file has no resources");
+       if (res != B_OK)
                return res;
-       }
 
        int mangledLanguage = CatKey::HashFun(fLanguageName.String(), 0);
 
        size_t sz;
-       const void *buf = rsrc.LoadResource('CADA',
-               mangledLanguage, &sz);
-       if (!buf) {
-               log_team(LOG_DEBUG, "file has no catalog-resource");
+       const void *buf = rsrc.LoadResource('CADA', mangledLanguage, &sz);
+       if (!buf)
                return B_NAME_NOT_FOUND;
-       }
 
        BMemoryIO memIO(buf, sz);
        res = Unflatten(&memIO);
@@ -540,11 +480,6 @@ DefaultCatalog::Unflatten(BDataIO *dataIO)
                // not accept this catalog:
                if (foundFingerprint != 0 && fFingerprint != 0
                        && foundFingerprint != fFingerprint) {
-                       log_team(LOG_INFO, "default-catalog(sig=%s, lang=%s) "
-                               "has mismatching fingerprint (%ld instead of 
the requested %ld), "
-                               "so this catalog is skipped.",
-                               fSignature.String(), fLanguageName.String(), 
foundFingerprint,
-                               fFingerprint);
                        res = B_MISMATCHED_VALUES;
                } else
                        fFingerprint = foundFingerprint;
@@ -580,14 +515,8 @@ DefaultCatalog::Unflatten(BDataIO *dataIO)
                        }
                }
                uint32 checkFP = ComputeFingerprint();
-               if (fFingerprint != checkFP) {
-                       log_team(LOG_WARNING, "default-catalog(sig=%s, lang=%s) 
"
-                               "has wrong fingerprint after load (%ld instead 
of the %ld). "
-                               "The catalog data may be corrupted, so this 
catalog is skipped.",
-                               fSignature.String(), fLanguageName.String(), 
checkFP,
-                               fFingerprint);
+               if (fFingerprint != checkFP)
                        return B_BAD_DATA;
-               }
        }
        return res;
 }
diff --git a/src/kits/locale/InitLocaleKit.cpp 
b/src/kits/locale/InitLocaleKit.cpp
index 96f281a..274b892 100644
--- a/src/kits/locale/InitLocaleKit.cpp
+++ b/src/kits/locale/InitLocaleKit.cpp
@@ -3,8 +3,6 @@
  * The required mimetypes and attribute-indices are created here.
  */
 
-#include <syslog.h>
-
 #include <fs_attr.h>
 #include <fs_index.h>
 #include <Volume.h>
@@ -35,19 +33,8 @@ static void EnsureIndexExists(const char *attrName)
        if (volRoster.GetBootVolume(&bootVol) != B_OK)
                return;
        struct index_info idxInfo;
-       if (fs_stat_index(bootVol.Device(), attrName, &idxInfo) != 0) {
-               status_t res = fs_create_index(bootVol.Device(), attrName,
-                       B_STRING_TYPE, 0);
-               if (res == 0) {
-                       log_team(LOG_INFO,
-                               "successfully created the required index for 
attribute %s",
-                               attrName);
-               } else {
-                       log_team(LOG_ERR,
-                               "failed to create the required index for 
attribute %s (%s)",
-                               attrName, strerror(res));
-               }
-       }
+       if (fs_stat_index(bootVol.Device(), attrName, &idxInfo) != 0)
+               fs_create_index(bootVol.Device(), attrName, B_STRING_TYPE, 0);
 }
 
 
@@ -122,10 +109,6 @@ SetupCatalogBasics()
                if (res == B_OK)
                        res = mt.Install();
        }
-       if (res != B_OK) {
-               log_team(LOG_ERR, "Could not install mimetype %s (%s)",
-                       DefaultCatalog::kCatMimeType, strerror(res));
-       }
 }
 
 
diff --git a/src/kits/locale/LocaleRoster.cpp b/src/kits/locale/LocaleRoster.cpp
index d13b614..c4238b9 100644
--- a/src/kits/locale/LocaleRoster.cpp
+++ b/src/kits/locale/LocaleRoster.cpp
@@ -14,7 +14,6 @@
 #include <set>
 
 #include <assert.h>
-#include <syslog.h>
 
 #include <Autolock.h>
 #include <Bitmap.h>
@@ -521,11 +520,8 @@ BLocaleRoster::GetLocalizedFileName(BString& 
localizedFileName,
        // The signature is missing application/
        signature.Prepend("application/");
        status = roster.FindApp(signature, &catalogRef);
-       if (status != B_OK) {
-               log_team(LOG_ERR, "Could not find the entry_ref for signature 
%s"
-                               " to load a catalog.", signature.String());
+       if (status != B_OK)
                return status;
-       }
 
        BCatalog catalog(catalogRef);
        const char* temp = catalog.GetString(string, context);
@@ -562,11 +558,8 @@ BLocaleRoster::_GetCatalog(BCatalog* catalog, vint32* 
catalogInitStatus)
                }
        }
 
-       if (!found) {
-               log_team(LOG_DEBUG, "Catalog %x doesn't belong to any image!",
-                       catalog);
+       if (!found)
                return catalog;
-       }
 
        // load the catalog for this mimetype and return it to the app
        entry_ref ref;
diff --git a/src/kits/locale/MutableLocaleRoster.cpp 
b/src/kits/locale/MutableLocaleRoster.cpp
index 3d51c99..2b4d606 100644
--- a/src/kits/locale/MutableLocaleRoster.cpp
+++ b/src/kits/locale/MutableLocaleRoster.cpp
@@ -13,7 +13,6 @@
 #include <set>
 
 #include <pthread.h>
-#include <syslog.h>
 
 #include <AppFileInfo.h>
 #include <Application.h>
@@ -91,13 +90,8 @@ CatalogAddOnInfo::MakeSureItsLoaded()
                                B_SYMBOL_TYPE_TEXT, (void**)&fCreateFunc);
                        get_image_symbol(fAddOnImage, "get_available_languages",
                                B_SYMBOL_TYPE_TEXT, (void**)&fLanguagesFunc);
-                       log_team(LOG_DEBUG, "catalog-add-on %s has been loaded",
-                               fName.String());
-               } else {
-                       log_team(LOG_DEBUG, "could not load catalog-add-on %s 
(%s)",
-                               fName.String(), strerror(fAddOnImage));
+               } else
                        return false;
-               }
        } else if (fIsEmbedded) {
                // The built-in catalog still has to provide this function
                fLanguagesFunc = default_catalog_get_available_languages;
@@ -115,8 +109,6 @@ CatalogAddOnInfo::UnloadIfPossible()
                fInstantiateFunc = NULL;
                fCreateFunc = NULL;
                fLanguagesFunc = NULL;
-//             log_team(LOG_DEBUG, "catalog-add-on %s has been unloaded",
-//                     fName.String());
        }
 }
 
@@ -176,7 +168,6 @@ RosterData::~RosterData()
        BAutolock lock(fLock);
 
        _CleanupCatalogAddOns();
-       closelog();
 }
 
 
@@ -320,11 +311,6 @@ RosterData::SetFilesystemTranslationPreferred(bool 
preferred)
 status_t
 RosterData::_Initialize()
 {
-       openlog_team("liblocale.so", LOG_PID, LOG_USER);
-#ifndef DEBUG
-       setlogmask_team(LOG_UPTO(LOG_WARNING));
-#endif
-
        status_t result = _InitializeCatalogAddOns();
        if (result != B_OK)
                return result;
@@ -429,16 +415,8 @@ RosterData::_InitializeCatalogAddOns()
                                                                priority = 
*prioPtr;
                                                                
node.WriteAttr(kPriorityAttr, B_INT8_TYPE, 0,
                                                                        
&priority, sizeof(int8));
-                                                       } else {
-                                                               
log_team(LOG_ERR,
-                                                                       
"couldn't get priority for add-on %s\n",
-                                                                       
fullAddOnPath.String());
                                                        }
                                                        unload_add_on(image);
-                                               } else {
-                                                       log_team(LOG_ERR,
-                                                               "couldn't load 
add-on %s, error: %s\n",
-                                                               
fullAddOnPath.String(), strerror(image));
                                                }
                                        }
 
@@ -793,11 +771,8 @@ MutableLocaleRoster::LoadSystemCatalog(BCatalog* catalog) 
const
                }
        }
 
-       if (!found) {
-               log_team(LOG_DEBUG, "Unable to find libbe-image!");
-
+       if (!found)
                return B_ERROR;
-       }
 
        // load the catalog for libbe into the given catalog
        entry_ref ref;


Other related posts:

  • » [haiku-commits] haiku: hrev44867 - src/kits/locale - zooey