APISonar


core.logging.Logger.log

> core > logging > Logger > log
core APIs logging APIs Logger APIs log APIs

Example 1
private static String getUserDataDirectory() {
        Path result = Paths.get(FileSystemView.getFileSystemView().getDefaultDirectory().getPath(), "GrassMarlin");

        try {
            Files.createDirectories(result);
        } catch(IOException ex) {
            Logger.log(Configuration.class, Severity.Error, "Unable to create user Data Directory: " + ex.getMessage());
        }
        return result.toString();
    }
Example 2
private void loadPhysical(InputSource source, Session session) throws IOException{
        try {
            SAXParser parser = SAXParserFactory.newInstance().newSAXParser();

            parser.parse(source, new PhysicalLoadHandler(session));
        } catch (SAXException | ParserConfigurationException e) {
            Logger.log(this, Severity.Error, "Error parsing session information");
        }
    }
Example 3
public static void parseSourceFile(Path file) {
        try(BufferedReader reader = Files.newBufferedReader(file, StandardCharsets.ISO_8859_1)) {
            String line;
            while((line = reader.readLine()) != null) {
                addResolverFromLine(line);
            }
            //TODO: sort by most precise to least precise for each bin
        } catch(IOException ioe) {
            Logger.log(Manufacturer.class, Severity.Error, "Unable to load MAC manufacturer reference: " + ioe.getMessage());
        }
    }
Example 4
public ImportCiscoShow(Path inPath) {
        super(inPath, null);

        try {
            this.sizeFile = Files.size(inPath);
        } catch (IOException e) {
            Logger.log(this, Severity.Warning, "Unable to find the size of file " + inPath.getFileName());
            this.sizeFile = 0;
        }
    }
Example 5
protected void addPendingImport(Attributes attributes, List<ImportDialog.PreliminaryImportItem> listPendingItems) {
        final ImportDialog.PreliminaryImportItem item = new ImportDialog.PreliminaryImportItem(new File(attributes.getValue("path")));
        final ImportProcessors.ProcessorWrapper wrapper = ImportProcessors.processorForName(attributes.getValue("type"));
        if(wrapper == null) {
            Logger.log(this, Severity.Error, "Unable to process import; plugin may be missing (" + attributes.getValue("type") + ")");
        } else {
            item.setType(wrapper);
            listPendingItems.add(item);
        }
    }
Example 6
protected void addImport(Attributes attributes, ImportList listImports) {
        //TODO: If/when serialization of fingerprint lists is supported, deserialization of fingerprint list goes here
        try {
            ImportItem item = ImportProcessors.newItem((Class<? extends ImportItem>)Launcher.loaderFor(attributes.getValue("plugin")).loadClass(attributes.getValue("type")), Paths.get(attributes.getValue("src")), null);
            item.recordTaskCompletion();
            listImports.add(item);
        } catch(ClassNotFoundException ex) {
            Logger.log(this, Severity.Error, "Unable to process import; plugin may be missing: " + ex.getMessage());
        }
    }
Example 7
public void ProcessImport(ImportItem importNew) {
        if(importNew instanceof LivePCAPImport) {
            getImports().add( ((LivePCAPImport)importNew).getSource() );
        } else {
            getImports().add(importNew);
        }
        if (!taskDispatcher().isRunning()) {
            taskDispatcher().run();
        }
        Logger.log(this, Severity.Information, "Beginning Import of " + importNew.toString());
        taskDispatcher().accept(importNew);
    }
Example 8
public void doAdd(int index, ImportItem item) {
        try {
            listInternal.add(index, item);
            OnImportAdded.call(new UpdateImportListItemArgs(this, item));
            OnListModified.call(argsUpdateList);
            //TODO: Remove event hooks when removed from the list.
            item.OnImportItemModified.addHandler((source, args) -> {
                OnImportUpdated.call(new UpdateImportListItemArgs(this, item));
            });
        } catch(Exception e) {
            Logger.log(this, Severity.Error, "Unable to process Import (" + item.toString() + "): " + e.getMessage());
            throw e;
        }
    }