• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Log类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.codename1.io.Log的典型用法代码示例。如果您正苦于以下问题:Java Log类的具体用法?Java Log怎么用?Java Log使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Log类属于com.codename1.io包,在下文中一共展示了Log类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: listenToMessages

import com.codename1.io.Log; //导入依赖的package包/类
private void listenToMessages() {
    try {
        pb = new Pubnub(PUBNUB_PUB_KEY, PUBNUB_SUB_KEY);
        pb.subscribe(tokenPrefix + uniqueId, new Callback() {
            @Override
            public void successCallback(String channel, Object message, String timetoken) {
                if(message instanceof String) {
                    pendingAck.remove(channel);
                    return;
                }
                Message m = new Message((JSONObject)message);
                pb.publish(tokenPrefix + m.getSenderId(),  "ACK", new Callback() {});
                Display.getInstance().callSerially(() -> {
                    addMessage(m);
                    respond(m);
                });
            }
        });
    } catch(PubnubException err) {
        Log.e(err);
        Dialog.show("Error", "There was a communication error: " + err, "OK", null);
    }
}
 
开发者ID:codenameone,项目名称:codenameone-demos,代码行数:24,代码来源:SocialChat.java


示例2: getDiskCache

import com.codename1.io.Log; //导入依赖的package包/类
/**
 * 
 */
private ArrayList<T> getDiskCache() throws IOException, JSONException{
    ArrayList<T> cacheArray = new ArrayList<>();
    
    InputStream fileStream = FileSystemStorage.getInstance().openInputStream(localCacheFile.getAbsolutePath());
    String fileContents = Util.readToString(fileStream);
    if(fileContents.length() > 1){
        JSONArray cacheJson = new JSONArray(fileContents);
        Log.p(this.getClass().getSimpleName() + ": Read " + cacheJson.length() + " entries from JSON cache", Log.INFO);

        for(int i = 0;i < cacheJson.length();i++){
            T obj = serializer.deserialize(cacheJson.getJSONObject(i));
            cacheArray.add(obj);
        }
    }else{
        Log.p(this.getClass().getSimpleName() + ": JSON cache empty", Log.INFO);
    }
    return cacheArray;
}
 
开发者ID:jegesh,项目名称:cn1-object-cacher,代码行数:22,代码来源:CacheFile.java


示例3: update

import com.codename1.io.Log; //导入依赖的package包/类
/**
 * 
 * @param obj Object to update 
 * @param notifier ignored if memory caching is used
 * @throws java.io.IOException if file doesn't exist
 * @throws ca.weblite.codename1.json.JSONException if the cache file has been corrupted 
 */
public void update(T obj, CacheErrorNotifier notifier) throws IOException, JSONException {
    if(cacheMap != null){
        cacheMap.put(serializer.getObjectId(obj), obj);
        return;
    }

    ArrayList<T> all = getDiskCache();
    for(int i = 0;i < all.size();i++){
        Object o = all.get(i);
        if(serializer.getObjectId((T)o).equals(serializer.getObjectId(obj))){
            all.add(i, obj);
            syncAll(all, notifier);
            return;
        }
    }
    Log.p(this.getClass().getSimpleName() + ": Attempted object update failed - "
            + "object with id " + serializer.getObjectId(obj) + " not found", Log.WARNING);
}
 
开发者ID:jegesh,项目名称:cn1-object-cacher,代码行数:26,代码来源:CacheFile.java


示例4: syncDiskCache

import com.codename1.io.Log; //导入依赖的package包/类
private void syncDiskCache(Collection<T> data, CacheErrorNotifier notifier){
    try {
                JSONArray dataArray = new JSONArray();
                for(T t: data)
                    dataArray.put(serializer.serialize(t));

                if (!localCacheFile.exists()) {
                    localCacheFile.createNewFile();
                }
                OutputStream outputStream = FileSystemStorage.getInstance().openOutputStream(localCacheFile.getAbsolutePath());
                    outputStream.write(dataArray.toString().getBytes());
                    outputStream.flush();
                
                Log.p(this.getClass().getSimpleName() + ": Synced " + dataArray.length() + " entries to cache file " + localCacheFile.getName(), Log.INFO);
            } catch (IOException ex) {
                ex.printStackTrace();
                if (notifier != null) {
                    notifier.notify(ex);
                }
            }
}
 
开发者ID:jegesh,项目名称:cn1-object-cacher,代码行数:22,代码来源:CacheFile.java


示例5: setDataSource

import com.codename1.io.Log; //导入依赖的package包/类
/**
 * Convenience JavaBean method, see other version of this method
 * @param uri the URL for the media
 */
public void setDataSource(final String uri) {
    if(!isInitialized()) {
        pendingDataURI = uri;
        return;
    }
    if(dataSource == null || !dataSource.equals(uri)) {
        Display.getInstance().startThread(new Runnable() {
            public void run() {
                try {
                    setDataSource(uri, null);
                } catch(Throwable t) {
                    Log.e(t);
                }
            }
        }, "Media Thread").start();
    }
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:22,代码来源:MediaPlayer.java


示例6: formatErrorMessage

import com.codename1.io.Log; //导入依赖的package包/类
private String formatErrorMessage(String message) {
    if (message.indexOf('\n') < 0) {
        return message;
    }
    
    List<String> lines = StringUtil.tokenize(message, '\n');
    StringBuilder sb = new StringBuilder();
    for (int i=1; i<lines.size(); i++) { // Note: Deliberately skip first line
        String line = lines.get(i);
        line = StringUtil.replaceAll(line, "\r", "");
        line = StringUtil.replaceAll(line, "at ", "");
        line = StringUtil.replaceAll(line, "userclasses.", "");
        line = StringUtil.replaceAll(line, "generated.", "");
        line = StringUtil.replaceAll(line, "com.codename1.", "");
        line = StringUtil.replaceAll(line, "com.codenameone.music.", "");
        sb.append(line);
    }
    Log.p(sb.toString());
    return sb.toString();
}
 
开发者ID:martijn00,项目名称:MusicPlayerCodenameOne,代码行数:21,代码来源:GoogleAnalyticsService.java


示例7: setStatus

import com.codename1.io.Log; //导入依赖的package包/类
private synchronized void setStatus(PlayerStatus status)
{
    Log.p("PlayerStatus changed to: " + status);
    this.status = status;

    statusChangeEvent.fireDataChangeEvent(0, status.ordinal());

    switch (status) {
        case STOPPED:
        case PAUSED:
            timer.cancel();
            timer = new Timer();
            break;

        case PLAYING:
            timer.scheduleAtFixedRate(new TimerTask() {
                @Override
                public void run() {
                    playingEvent.fireActionEvent(null);
                }
            }, 0, 1000);
            break;
    }
}
 
开发者ID:martijn00,项目名称:MusicPlayerCodenameOne,代码行数:25,代码来源:MediaPlayer.java


示例8: equals

import com.codename1.io.Log; //导入依赖的package包/类
@Override
public boolean equals(Object o) {
    int id = MediaHelper.getId(track);
    String language = (String)track.get("language");

    if (o instanceof Map) {
        if (((Map) o).containsKey("type") && "track".equals(((Map) o).get("type"))) {
            if (language.equals(((Map) o).get("language")) && id == MediaHelper.getId((Map) o)) {
                Log.p("MediaRunnable: Instance is equal - " + id + " " + language);
                return true;
            }
        }
    }

    if (o instanceof MediaItem) {
        if (this.track == ((MediaItem) o).track) {
            Log.p("MediaRunnable: Instance is equal - " + id + " " + language);
            return true;
        }
    }

    Log.p("MediaRunnable: Instance is not equal - " + id + " " + language);

    return false;
}
 
开发者ID:martijn00,项目名称:MusicPlayerCodenameOne,代码行数:26,代码来源:MediaItem.java


示例9: exitForm

import com.codename1.io.Log; //导入依赖的package包/类
@Override
protected void exitForm(Form f) {
    super.exitForm(f);

    requests = (java.util.List<ConnectionRequest>) f.getClientProperty("requests");

    if (requests == null) {
        return;
    }

    for(ConnectionRequest request : requests) {
        Log.p("Killed request " + request.getUrl());

        request.kill();
    }

    requests.clear();

    f.putClientProperty("requests", requests);
}
 
开发者ID:martijn00,项目名称:MusicPlayerCodenameOne,代码行数:21,代码来源:StateMachine.java


示例10: start

import com.codename1.io.Log; //导入依赖的package包/类
public void start() {
    if(current != null){
        current.show();
        return;
    }
    s = new StateMachine("/theme");        
    
    Display.getInstance().addEdtErrorHandler(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            evt.consume();
            Log.p("Exception in AppName version " + Display.getInstance().getProperty("AppVersion", "Unknown"));
            Log.p("OS " + Display.getInstance().getPlatformName());
            Log.p("Error " + evt.getSource());
            Log.p("Current Form " + Display.getInstance().getCurrent().getName());
            Log.e((Throwable)evt.getSource());
            Log.sendLog();
        }
    });
}
 
开发者ID:codenameone,项目名称:codenameone-demos,代码行数:20,代码来源:PushDemo.java


示例11: Message

import com.codename1.io.Log; //导入依赖的package包/类
public Message(JSONObject obj) {
    try {
        time = Long.parseLong(obj.getString("time"));
        senderId = obj.getString("fromId");
        recepientId = obj.getString("toId");
        message = obj.getString("message");
        name = obj.getString("name");
        picture = obj.getString("pic");
        
        // update the push id for the given user
        if(obj.has("pushId")) {
            String pushId = obj.getString("pushId");
            if(pushId != null) {
                Preferences.set("pid-" + senderId, pushId);
            }
        }
    } catch (JSONException ex) {
        // will this ever happen?
        Log.e(ex);
    }        
}
 
开发者ID:codenameone,项目名称:codenameone-demos,代码行数:22,代码来源:Message.java


示例12: getImageData

import com.codename1.io.Log; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
public byte[] getImageData() {
    if(data != null) {
        return data;
    }
    InputStream i = null;
    try {
        byte[] imageData = new byte[(int) FileSystemStorage.getInstance().getLength(fileName)];
        i = FileSystemStorage.getInstance().openInputStream(fileName);
        Util.readFully(i, imageData);
        if(keep) {
            data = imageData;
        }
        return imageData;
    } catch (IOException ex) {
        Log.e(ex);
        return null;
    } finally {
        Util.cleanup(i);
    }
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:24,代码来源:FileEncodedImage.java


示例13: refreshZoom

import com.codename1.io.Log; //导入依赖的package包/类
void refreshZoom(Container solitairContainer) {
    int dpi =  DPIS[currentZoom / 5];
    Preferences.set("dpi", dpi);
    Preferences.set("zoom", currentZoom);
    try {
        cards = Resources.open("/gamedata.res",dpi);
        cardImageCache.clear();
        Image cardBack = getCardImage("card_back.png");
        for(Component c : solitairContainer) {
            CardComponent crd = (CardComponent)c;
            crd.setImages(getCardImage(crd.getCard().getFileName()), cardBack);
        }
        solitairContainer.revalidate();
        solitairContainer.getParent().replace(solitairContainer.getParent().getComponentAt(0), createPlacementContainer(solitairContainer), null);
    } catch(IOException e) {
        Log.e(e);
    }        
}
 
开发者ID:codenameone,项目名称:codenameone-demos,代码行数:19,代码来源:Solitaire.java


示例14: initListModelSqlData

import com.codename1.io.Log; //导入依赖的package包/类
@Override
protected boolean initListModelSqlData(List cmp) {
    Database d = getDb();
    if(d != null) {
        try {
            Cursor c = d.executeQuery("select title, description from log");
            Vector entries = new Vector();
            while (c.next()) {
                Row r = c.getRow();
                String title = r.getString(0);
                String desc = r.getString(1);

                Hashtable value = new Hashtable();
                value.put("Line1", title);
                value.put("Line2", desc);
                entries.addElement(value);
                cmp.setModel(new DefaultListModel(entries));
            }
        } catch (IOException ex) {
            Log.e(ex);
        }

    }
    return true;
}
 
开发者ID:codenameone,项目名称:codenameone-demos,代码行数:26,代码来源:StateMachine.java


示例15: init

import com.codename1.io.Log; //导入依赖的package包/类
/**
 * Installs a crash reporter within the system
 * @param promptUser indicates whether the user should be prompted on crash reporting
 * @param frequency the frequency with which we send the log to the server in debug mode in minutes
 * frequency must be at least 1. Any lower level automatically disables this feature
 */
public static void init(boolean promptUser, int frequency) {
    if(Preferences.get("$CN1_crashBlocked", false) || Log.getReportingLevel() == Log.REPORTING_NONE) {
        return;
    }
    if(Preferences.get("$CN1_pendingCrash", false)) {
        // we must have crashed during a report, send it.
        Log.sendLog();
        Preferences.set("$CN1_pendingCrash", false);
    }
    if(Log.getReportingLevel() == Log.REPORTING_DEBUG && frequency > 0) {
        java.util.Timer t = new java.util.Timer();
        t.schedule(new TimerTask() {
            public void run() {
                if(!Display.getInstance().isEdt()) {
                    Display.getInstance().callSerially(this);
                    return;
                }
                Log.sendLog();
            }
        }, frequency * 60000, frequency * 60000);
    }
    DefaultCrashReporter d = new DefaultCrashReporter();
    d.promptUser = promptUser && Preferences.get("$CN1_prompt", true);
    Display.getInstance().setCrashReporter(d);
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:32,代码来源:DefaultCrashReporter.java


示例16: nativeLogout

import com.codename1.io.Log; //导入依赖的package包/类
@Override
public void nativeLogout() {
    
    getClient(new SuccessCallback<GoogleApiClient>() {

        @Override
        public void onSucess(final GoogleApiClient client) {
            Auth.GoogleSignInApi.signOut(client).setResultCallback(
                new ResultCallback<Status>() {
                    @Override
                    public void onResult(Status status) {
                        Log.p("Finished signing out "+status);
                        setAccessToken(null);
                        mGoogleApiClient = null;
                        client.disconnect();
                    }
                });
        }
        
    });
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:22,代码来源:GoogleImpl.java


示例17: showModal

import com.codename1.io.Log; //导入依赖的package包/类
void showModal(int top, int bottom, int left, int right, boolean includeTitle, boolean modal, boolean reverse) {
    if(Display.isInitialized() && Display.getInstance().isMinimized()){
        Log.p("Modal dialogs cannot be displayed on a minimized app");
        return;
    }
    this.top = top;
    this.bottom = bottom;
    this.left = left;
    this.right = right;
    
    // hide the title if no text is there to allow the styles of the dialog title to disappear
    if(dialogTitle != null && getUIManager().isThemeConstant("hideEmptyTitleBool", false)) {
        boolean b = dialogTitle.getText().length() > 0;
        getTitleArea().setVisible(b);
        getTitleComponent().setVisible(b);
    }
    super.showModal(top, bottom, left, right, includeTitle, modal, reverse);
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:19,代码来源:Dialog.java


示例18: getGeofenceListener

import com.codename1.io.Log; //导入依赖的package包/类
GeofenceListener getGeofenceListener(String id) {
    if (geofenceListeners().containsKey(id)) {
        Class cls = null;
        try {
            cls = Class.forName(geofenceListeners.get(id)); 
            if (cls == null) {
                return null;
            }
            return (GeofenceListener)cls.newInstance();
        } catch (Throwable t) {
            Log.e(t);
        }
        
    }
    return null;
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:17,代码来源:IOSImplementation.java


示例19: nativeFillShape

import com.codename1.io.Log; //导入依赖的package包/类
/**
 * Fills a shape in the graphics context.
 * @param shape
 */
void nativeFillShape(Shape shape) {
    if (shape.getClass() == GeneralPath.class) {
        // GeneralPath gives us some easy access to the points
        GeneralPath p = (GeneralPath)shape;
        int commandsLen = p.getTypesSize();
        int pointsLen = p.getPointsSize();
        byte[] commandsArr = getTmpNativeDrawShape_commands(commandsLen);
        float[] pointsArr = getTmpNativeDrawShape_coords(pointsLen);
        p.getTypes(commandsArr);
        p.getPoints(pointsArr);
        
        nativeInstance.nativeFillShapeMutable(color, alpha, commandsLen, commandsArr, pointsLen, pointsArr);
    } else {
        Log.p("Drawing shapes that are not GeneralPath objects is not yet supported on mutable images.");
    }
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:21,代码来源:IOSImplementation.java


示例20: getHostOrIP

import com.codename1.io.Log; //导入依赖的package包/类
@Override
public String getHostOrIP() {
    try {
        InetAddress i = java.net.InetAddress.getLocalHost();
        if(i.isLoopbackAddress()) {
            Enumeration<NetworkInterface> nie = NetworkInterface.getNetworkInterfaces();
            while(nie.hasMoreElements()) {
                NetworkInterface current = nie.nextElement();
                if(!current.isLoopback()) {
                    Enumeration<InetAddress> iae = current.getInetAddresses();
                    while(iae.hasMoreElements()) {
                        InetAddress currentI = iae.nextElement();
                        if(!currentI.isLoopbackAddress()) {
                            return currentI.getHostAddress();
                        }
                    }
                }
            }
        }
        return i.getHostAddress();
    } catch(Throwable t) {
        Log.e(t);
        return null;
    }
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:26,代码来源:JavaSEPort.java



注:本文中的com.codename1.io.Log类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Resource类代码示例发布时间:2022-05-22
下一篇:
Java OSRMRoadManager类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap